Re: fork()/exec() and X11 streams usage.
Re: fork()/exec() and X11 streams usage.
- Subject: Re: fork()/exec() and X11 streams usage.
- From: Jeremy Huddleston Sequoia <email@hidden>
- Date: Mon, 08 Oct 2012 18:43:33 -0700
Yeah, I pretty much mirror what Brandon mentioned with on additional comment. You should really use posix_spawn instead of fork/exec unless you really need to do something "special" pre-exec.
On Oct 8, 2012, at 5:27 PM, Brandon Allbery <email@hidden> wrote:
> On Mon, Oct 8, 2012 at 5:42 PM, Robert Tillyard <email@hidden> wrote:
> While trying to investigate this it seems that calling fork() and exec() to run sub-processes where the parent process blocks could be the problem, once fork() is called we use waitpid() to get the return from the child but
>
> That's likely to cause some kind of problems in any case (you are not processing events), but if it's causing a streams panic on SCO then that is a kernel problem. I would not expect a similar problem on OS X.
>
> if we use WNOHAND and sit in a loop calling some qApp->flushX11() routine the MBLKs in streams is kept low.
>
> 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).
>
> --
> brandon s allbery kf8nh sine nomine associates
> email@hidden email@hidden
> unix/linux, openafs, kerberos, infrastructure http://sinenomine.net
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> X11-users mailing list (email@hidden)
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
X11-users mailing list (email@hidden)
This email sent to email@hidden