From: Dave D. <dde...@es...> - 2006-08-02 09:02:06
|
Timoth=E9e Lecomte <tim...@en...> writes: >>>>> >>>> gnuplot can fork(), then allow the parent to exit, leaving the child >>>> continuing to run the same code in exactly the same state, but >>>> detached. >>> and because exiting >>> the parent would close file and socket descriptors, thus closing the >>> connection to the X server. >>> >> >> No, the child inherits the open files. >> > It does, but when the parent calls exit(), the corresponding files are > closed. There is a workaround : _exit(), but again, I think it becomes > too complicated and less portable. >> exit() can cause problems, but it doesn't close the files and sockets. Or at least, it closes the parent's handles, but the child's handles mean the underlying instance remains open. Parent exit() does cause stdio to get cleaned up, which can confuse things. I rather assumed that as soon as we started discussing fork() we were in a unix-only scenario. >>> A workaround would be to close the GUI >>> thread and the windows before the fork() and to open them again in the >>> child, but I'm not sure maxima users would appreciate to see their >>> window disappearing and reappearing... >>> >>> >> >> >> One other option would always be to immediately fork, but keep the >> parent around as a dummy process (just so that the original process >> knows it's still active). So all the work would happen in the child. >> In effect, code it as if you always detach, and then keep the parent >> alive as a workaround to stop the original process thinking the child >> has exited until the child chooses to detach. >> > I wonder what happens regarding the command line then. > Shouldn't really notice anything happening. Both parent and child have stdin open, (or maybe parent closes it), but only child is actually reading from it, and so it doesn't matter. (After all, if you launch gnuplot interactively from a shell, the shell still has the stdin stream open. But it just isn't reading from it.) dd --=20 Dave Denholm <dde...@es...> http://www.esmertec= .com |