Re: [gtk-list] Re: Proper way to fork() a GTK program (to exec() something)



Eric wrote:

> This poses a little problem:  What if a GTK application wants to execute
> a program and, say, give the user some buttons to kill the program using
> various signals?  That program very well might be using exit(), and thus
> screw up your application.

There are several solutions for that. After fork(), but before exec()
in child, you can close all file descriptors except the first three (if
you need them), and that should do the trick. Get the current soft limit
of file descriptors with getrlimit() and close everything. It is
expensive, but this is how some other programs solve that task. Threaded
web servers when executing CGI program, for example.

You could also override exit() with LD_PRELOAD on platforms which support
that, but I think this is an overkill.

-- 
 .-.   .-.    Life is a sexually transmitted disease.
(_  \ /  _)
     |        dave@srce.hr
     |        dave@fly.cc.fer.hr



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]