Re: g_spawn_async blocking issue
- From: Owen Taylor <otaylor redhat com>
- To: <pin doomed org>
- Cc: <gtk-devel-list gnome org>
- Subject: Re: g_spawn_async blocking issue
- Date: Sat, 28 Dec 2002 16:41:29 -0500 (EST)
<pin doomed org> writes:
> Well, I was just wondering about g_spawn_with_pipes.. I use it to execute
> an external program for me.. Under FreeBSD (at least) when it is run at
> the same time i got sound playing with a thread through ESD.. the
> g_spawn.. seems to block the main process.
>
> The only solution I found to make it stop blocking was with some code
> similar to the following:
>
> if (fork() == 0) {
> register int cnt;
>
> /* close all the fds in the child to prevent it from hogging thea udio
> device */
> for (cnt = 3; cnt < 255; cnt++)
> close(cnt);
>
> exec...
> _exit(0);
> }
>
> and well, now it does not block. I was just wondering if there is some
> similar code in the gspawn part in the glib, but I have not checked
> myself. I think there should be something like this, since this forked
> child should not need those fds anyway..
It does it unless you specify otherwise. (Using the CLOEXEC flag
for fcntl, rather than close())
http://developer.gnome.org/doc/API/2.2/glib/glib-Spawning-Processes.html#GSpawnFlags
You generally want to ask questions about programming with Glib
on gtk-app-devel-list rather than here .. this list is about
the development of GLib and GTK+.
Regards,
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]