Should execv() call _run_exitfuncs()? If not, should _run_exitfuncs() be private?
As a hobby I've been writing a debugger. One of the commands,"restart", works by calling an execv(). You may need to do this when the program you are debugging is threaded or when one needs to ensure that all program state is reinitialized. Recently, I added remote debugging via TCP sockets and noticed that execv() in Python doesn't arrange exit hooks to get called. Should it? One can run _run_exitfuncs() from the atexit module, but the leading underscore of the function call suggests it is private. Should it be? Thanks
On Sat, Jan 31, 2009 at 4:55 PM, Rocky Bernstein <rocky@gnu.org> wrote:
As a hobby I've been writing a debugger. One of the commands,"restart", works by calling an execv(). You may need to do this when the program you are debugging is threaded or when one needs to ensure that all program state is reinitialized.
Recently, I added remote debugging via TCP sockets and noticed that execv() in Python doesn't arrange exit hooks to get called. Should it?
One can run _run_exitfuncs() from the atexit module, but the leading underscore of the function call suggests it is private. Should it be?
Depending on the use for the exit function you might or might not want it run at the occasion of exec*(). E.g. I imagine that in a typical fork() + exec*() scenario, calling the exit functions in the child process would be a mistake. So I don't think the hooks should be called by default. However you are welcome to call the function (leading underscore and all) if it helps in your case. -- --Guido van Rossum (home page: http://www.python.org/~guido/)
Guido van Rossum writes:
Depending on the use for the exit function you might or might not want it run at the occasion of exec*(). E.g. I imagine that in a typical fork() + exec*() scenario, calling the exit functions in the child process would be a mistake.
So I don't think the hooks should be called by default. However you are welcome to call the function (leading underscore and all) if it helps in your case.
Ok - got it. Thanks, everyone, for the clarification(s).
Rocky Bernstein wrote:
As a hobby I've been writing a debugger. One of the commands,"restart", works by calling an execv(). You may need to do this when the program you are debugging is threaded or when one needs to ensure that all program state is reinitialized.
Recently, I added remote debugging via TCP sockets and noticed that execv() in Python doesn't arrange exit hooks to get called. Should it?
One can run _run_exitfuncs() from the atexit module, but the leading underscore of the function call suggests it is private. Should it be?
One of the advantages in Python handling 'private' APIs by convention rather than having it enforced by the compiler is that for some applications (like debuggers), a higher degree of coupling is more appropriate than sticking strictly to the public, guaranteed stable API. So I'd say call the private API anyway. While in theory it *could* change, it probably won't, and the use case is too esoteric to justify the overhead of making it public. Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia ---------------------------------------------------------------
participants (4)
-
Guido van Rossum
-
Nick Coghlan
-
Rocky Bernstein
-
rocky@gnu.org