delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/1998/06/15/07:41:40

From: cgf AT cygnus DOT com (Christopher Faylor)
Subject: Re: system() fix.
15 Jun 1998 07:41:40 -0700 :
Message-ID: <199806151437.KAA30320.cygnus.cygwin32.developers@kramden.cygnus.com>
To: cygwin32-developers AT cygnus DOT com, sos AT prospect DOT com DOT ru

This looks almost right, but the linux man page says that SIGCHLD is blocked
while SIGQUIT and SIGINT are ignored.  That sounds right, actually, because
otherwise a program could miss notification of child termination.

I modified your patch to work as below.  If you agree with it, I'll check
the change in immediately.

cgf

>From: Sergey Okhapkin <sos AT prospect DOT com DOT ru>
>Date: Mon, 15 Jun 1998 16:36:05 +0400
>
>syscalls.cc:	(system): ignore SIGINT, SIGQUIT and SIGCHLD while in a system() call.
>

New patch:

Index: syscalls.cc
===================================================================
RCS file: /cvs/cvsfiles/devo/winsup/syscalls.cc,v
retrieving revision 1.103
diff -w -u -r1.103 syscalls.cc
--- syscalls.cc	1998/06/09 14:54:59	1.103
+++ syscalls.cc	1998/06/15 14:34:11
@@ -1306,10 +1306,18 @@
 {
   int res;
   const char* command[4];
+  _sig_func_ptr oldint, oldquit;
+  sigset_t child_block, old_mask;
 
   if (cmdstring == (const char *) NULL)
         return 1;
 
+  oldint = signal (SIGINT, SIG_IGN);
+  oldquit = signal (SIGQUIT, SIG_IGN);
+  sigemptyset (&child_block);
+  sigaddset (&child_block, SIGCHLD);
+  (void) sigprocmask (SIG_BLOCK, &child_block, &old_mask);
+
   command[0] = "sh";
   command[1] = "-c";
   command[2] = cmdstring;
@@ -1322,6 +1330,9 @@
       res = 127;
     }
 
+  signal (SIGINT, oldint);
+  signal (SIGQUIT, oldquit);
+  (void) sigprocmask (SIG_SETMASK, &old_mask, 0);
   return res;
 }
 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019