|
From: <tim...@en...> - 2006-08-01 23:29:07
|
Dave Denholm wrote: > Timoth=E9e Lecomte <tim...@en...> writes: > > =20 >> Dave Denholm wrote: >> =20 >>>> - mimic a 'bg' to gnuplot. Well, I don't know how to do that from >>>> gnuplot, and I doubt it will actually work : since gnuplot's >>>> process is still running, octave still waits for it. >>>> >>>> Do any of you have a miraculous idea, or should I report that to >>>> the octave developers as I did for maxima ? >>>> >>>> >>>> =20 >>> 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. >>> >>> =20 >> This won't work in my case, because the terminal is multithreaded and >> fork() has undetermined behaviour with threads, >> =20 > > Not really... you can install fork handlers (assuming pthreads). But > yes, it all becomes horribly complicated. See pthread_atfork() > =20 Well, you're right, especially when you say "horribly complicated" ;) > > =20 >> and because exiting >> the parent would close file and socket descriptors, thus closing the >> connection to the X server. >> =20 > > No, the child inherits the open files. > =20 It does, but when the parent calls exit(), the corresponding files are=20 closed. There is a workaround : _exit(), but again, I think it becomes=20 too complicated and less portable. > =20 >> 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... >> >> =20 > > > 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. > =20 I wonder what happens regarding the command line then. Anyway, I would *really* prefer not to have to play with fork() just to=20 satisfy a particular use case that is not written word for word=20 anywhere. I am sure the maxima folks will find a nice workaround=20 (there's already one workaround: defining a simple shell wrapper that=20 launches gnuplot in the background) (I would be glad to help them if=20 only it wouldn't be coded in lisp...). Timoth=E9e |