Re: fork()/exec() and X11 streams usage.
Re: fork()/exec() and X11 streams usage.
- Subject: Re: fork()/exec() and X11 streams usage.
- From: Robert Tillyard <email@hidden>
- Date: Fri, 12 Oct 2012 17:43:59 +0100
Thanks, for your reply,
In this case what I'm trying to do is to hibernate the parent process and stop it using un-necessary CPU and even allow it to be swapped out as some of these modules are only used for a part of the process and not accessed again for some time.
Prior to fork()/exec() being called the X11 app is hidden so that the new sub-process appears to be a new main window of the app so I didn't think that the old hidden parent would need to process events.
In experimentation by not blocking and allowing events to be processed we now have problems where memory usage is high because these hibernating parent processes are not being swapped out because they are doing work in the background and the number or process switches in high.
More experimentation required I think...
Thanks, regards, Rob. On 9 Oct 2012, at 01:27, Brandon Allbery wrote: You should really be doing something like this anyway, as your program should process X11 events instead of completely blocking. But "something like this" is not exactly this.
Correct handling depends on what exactly you are doing; my general answer is to use a SIGCHLD handler to detect child exit and do the waitpid(), and if some synchronization is needed then it should arrange for the event loop to be triggered (XSendMessage() yourself to be picked up by XNextEvent(), write on a second file descriptor with a main loop that select()s/poll()s on that and the X11 socket, etc. as appropriate).
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
X11-users mailing list (email@hidden)
This email sent to email@hidden