Help: /bin/ping problem with Red Hat
Vivek Sawant
vivek-killspam at cs.unc.edu
Wed Mar 12 14:39:37 EST 2003
Jeff,
That worked! Thanks a zillion for replying with that code fragment. That
was a *huge* help. Thanks again.
Wish the same think can be achieved from within Python.
\vivek
Jeff Epler wrote:
>system(), spawn*() and/or fork+exec from a Python thread on Linux tends to do
>strange things. I believe it has to do with changes to signal handling
>done by linux pthreads implementation which are not undone when a new
>process is exec()'d.
>
>The following program sets all signals back to the default and then
>executes the given program. Using a wrapper like this might let the
>system()'d program execute properly (system("xxx") becomes system("rehup
>xxx"))
>
>#include <signal.h>
>
>int main(int c, char **v) {
> int i;
> sigset_t sset;
>
> sigemptyset(&sset);
> if (sigprocmask(SIG_SETMASK, &sset, 0) == -1) perror("sigprocmask");
> for(i=0; i<32; i++) {
> if(signal(i, SIG_DFL) == SIG_ERR) perror("signal");
> }
> execv(v[1], &v[1]);
> perror("execv");
> return 1;
>}
>
>
>
More information about the Python-list
mailing list