Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com X-Lotus-FromDomain: KINDLE From: Gary_Rowe AT kindlesystems DOT com To: cygwin AT cygwin DOT com Message-ID: <00256A0E.0058B7DB.00@SMTP-NOTES.Kindlesystems.com> Date: Tue, 13 Mar 2001 15:53:16 +0000 Subject: Strange behaviour of Signals under Cygwin Mime-Version: 1.0 Content-type: text/plain; charset=us-ascii Content-Disposition: inline Hi, There appears to be a problem with signal handling in Cygwin, whereby it is possible under load for signals not to be delivered to the process they have been sent to when expected. However, they only appear to be deferred, and are delivered on receipt of a subsequent signal. To test this, I used the following stand-alone program, and passed signals to it using the "kill(1)" command: Test program "sighand.c": ------------------------- ===================================================== #include #include #include #include /* Test signal handler */ #ifdef USE_SIGACTION struct sigaction sAction,sOld; #endif /* Counters and running flag */ int iInt = 0; int iUsr1 = 0; int iAlarm = 0; int bRunning = 0; /* Forward declaration of handler */ void trap(int); main() { #ifdef USE_SIGACTION /* Set signal disposition using sigaction() */ printf("sighand: using sigaction()\n"); sigemptyset(&(sAction.sa_mask)); sAction.sa_handler = trap; sAction.sa_flags = 0; if (sigaction(SIGINT,&sAction,&sOld) == -1) perror("sigaction(INT)"); if (sigaction(SIGUSR1,&sAction,&sOld) == -1) perror("sigaction(USR1)"); if (sigaction(SIGALRM,&sAction,&sOld) == -1) perror("sigaction(ALRM)"); if (sigaction(SIGTERM,&sAction,&sOld) == -1) perror("sigaction(TERM)"); #else /* Set signal disposition using signal() */ printf("sighand: using signal()\n"); signal(SIGINT,trap); signal(SIGUSR1,trap); signal(SIGALRM,trap); signal(SIGTERM,trap); #endif /* Main loop - run until SIGTERM resets run flag */ bRunning = 1; while (bRunning) pause(); /* Report signal counts */ printf("SIGINT : %d received\n",iInt); printf("SIGUSR1: %d received\n",iUsr1); printf("SIGALRM: %d received\n",iAlarm); exit(0); } /* Signal trap */ void trap(int iSig) { /* Report and bump counter: SIGTERM stops run */ printf("Trapped signal %d\n",iSig); switch (iSig) { case SIGINT: iInt++; break; case SIGUSR1: iUsr1++; break; case SIGALRM: iAlarm++; break; case SIGTERM: bRunning = 0; break; } /* If using signal(), we must reset! */ #ifndef USE_SIGACTION signal(iSig,trap); #endif return; } ===================================================== Compilation: $ gcc [-DUSE_SIGACTION] sighand.c -o sighand Test commands issued (from another bash): ----------------------------------------- Find the PID of sighand, then $ for n in 1 2 3 4 5 6 7 8 9 10; do kill -USR1 ; done $ kill -INT (kill -INT repeated until no more SIGUSR1s are reported) $ kill Output of signand after above test: ----------------------------------- sighand: using sigaction() Trapped signal 30 Trapped signal 30 Trapped signal 2 Trapped signal 30 Trapped signal 2 Trapped signal 30 Trapped signal 2 Trapped signal 30 Trapped signal 2 Trapped signal 30 Trapped signal 2 Trapped signal 30 Trapped signal 30 Trapped signal 2 Trapped signal 30 Trapped signal 2 Trapped signal 30 Trapped signal 2 Trapped signal 2 Trapped signal 15 SIGINT : 9 received SIGUSR1: 10 received SIGALRM: 0 received The output is similar, whether the program is compiled with "-DUSE_SIGACTION" or not. Can anyone throw any light on this - is there something I'm missing, or is it something I'll have to live with? And before you ask, NO, I haven't the experience (yet :-) to debug the Cygwin code and patch it! Regards, Gary Rowe ----------------- Output of "cygcheck -srv" follows: ---------------------------------- Cygnus Win95/NT Configuration Diagnostics Current System Time: Tue Mar 13 15:00:37 2001 WinNT Ver 4.0 build 1381 Service Pack 5 Path: /r7systems/bin.nt4 /usr/local/bin /usr/bin /bin /cygdrive/c/WINNT/system32 /cygdrive/c/WINNT /cygdrive/c/PROGRA~1/TCL/bin /usr/bin /usr/local/bin /cygdrive/c/NetExpress/base/BIN /cygdrive/c/MSDEV/BIN /cygdrive/c/dos . /emacs-20.7/bin /cobol/BIN SysDir: C:\WINNT\System32 WinDir: C:\WINNT PWD = `/home/angus/test' USER = `angus' MAKE_MODE = `unix' HOME = `/home/angus' NUMBER_OF_PROCESSORS = `1' PROMPT = `$P$G' LOGONSERVER = `\\GARYDESK' OS2LIBPATH = `C:\WINNT\system32\os2\dll;' COMSPEC = `C:\WINNT\system32\cmd.exe' IS = `/r7systems' LASTREL = `7.00.0' !C: = `C:\cygwin\bin' YCFLAGS = `-DNT4 -DISAMDLL' SYSTEMDRIVE = `C:' SYSREL = `NT4_SP5_CYGWIN-1.1.4' HOSTNAME = `GARYDESK' INCLUDE = `c:\msdev\include;c:\msdev\mfc\include;%include%' PROCESSOR_REVISION = `0703' MSDEVDIR = `C:\MSDEV' CISAM = `/usr/local/cisam' OS_LIBS = `-lcompat -lcygipc -lcygwin -lkernel32 -L/usr/local/cisam/lib -lisam' PATHEXT = `.COM;.EXE;.BAT;.CMD' COMPUTERNAME = `GARYDESK' WINDIR = `C:\WINNT' USERPROFILE = `C:\WINNT\Profiles\angus' LS = `/r7systems/lib.nt4' OS_CIOS = `' PS1 = `$PWD\$ ' SYS = `/r7systems' MS = `/r7systems/messages' COBRTS = `CBLRTSS' MANDIR = `/r7systems/man' LCFLAGS = `-DNT4 -DISAMDLL' M = `d:/bankmaster/messages' SHL_EXT = `DLL' MACHTYPE = `i686-pc-cygwin' COBLIB = `/cobol/LIB' PROCESSOR_IDENTIFIER = `x86 Family 6 Model 7 Stepping 3, GenuineIntel' OS = `Windows_NT' OLDPWD = `/home/angus' BS = `/r7systems/bin.nt4' PROCESSOR_ARCHITECTURE = `x86' TEMP = `/cygdrive/c/TEMP' PROCESSOR_LEVEL = `6' SYSTEMROOT = `C:\WINNT' CS = `/r7systems/config' PLATFORM = `NT4' HOMEDRIVE = `C:' LIB = `c:\msdev\lib;c:\msdev\mfc\lib;%lib%' SHLVL = `1' LOGNAME = `angus' HOMEPATH = `\' USERDOMAIN = `GARYDESK' MSC = `/r7systems/messages' OS_FLAGS = `-DNT4 -DISAMDLL' USERNAME = `Angus' SHELL = `/bin/sh' HOSTTYPE = `i686' OS_DMS = `' OSTYPE = `cygwin' TERM = `pcansi' _ = `/usr/bin/cygcheck.exe' TZ = `IST-5:30' HKEY_CURRENT_USER\Software\Cygnus Solutions HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2 (default) = `/cygdrive' cygdrive flags = 0x00000022 HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2\/bankmaster (default) = `d:\bankmaster' flags = 0x00000000 HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2\/cobol (default) = `d:\netexpress\base' flags = 0x00000000 HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2\/copylib (default) = `d:\copylib' flags = 0x00000000 HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2\/download (default) = `d:\download' flags = 0x00000002 HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2\/nusrc (default) = `g:\vol1\port\tpg217' flags = 0x00000000 HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2\/port (default) = `d:\r7systems.old' flags = 0x00000002 HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2\/r7systems (default) = `d:\r7systems' flags = 0x00000002 HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2\/temp (default) = `d:\temp' flags = 0x00000000 HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\Program Options HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\Installed Components HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\Installed Components\C:/cygwin (default) = `20000517' bash = `0002.0004.0001' binutils = `19990818.0002' bison = `0000' byacc = `0000' bzip = `0000' clear = `0001.0000' crypt = `0001.0000' cygwin = `0001.0001.0002' dejagnu = `0000' diff = `0TAR.00GZ' expect = `0000' fileutils = `0000' findutils = `0000' flex = `0TAR.00GZ' gawk = `0TAR.00GZ' gcc = `0002.0095.0002.0002' gdb = `20000610' gperf = `0000' grep = `0TAR.00GZ' groff = `0001.011a.0001' inetutils = `0001.0003.0002.0004' less = `0TAR.00GZ' libpng = `0001.0000.0006.0001' login = `0001.0003' m = `0TAR.00GZ' make = `0003.0079.0001' man = `0001.005g.0002' patch = `0000' sed = `0003.0002.0001' shellutils = `0000' tar = `0TAR.00GZ' tcltk = `20000610' termcap = `20000618.0001' texinfo = `0000' textutils = `0000' time = `0TAR.00GZ' zlib = `0001.0001.0003.0001' GZIP = `0TAR.00GZ' HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2 HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/ (default) = `c:\cygwin' flags = 0x0000000a HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/usr/bin (default) = `c:/cygwin/bin' flags = 0x0000000a HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/usr/lib (default) = `c:/cygwin/lib' flags = 0x0000000a HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\Program Options HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup\b15.0 HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts\00 HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts\01 HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts\02 HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts\03 HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts\04 HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts\05 HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts\06 HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts\07 HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts\08 HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts\09 HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts\0A HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts\0B HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts\0C HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts\0D HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts\0E HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts\0F HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts\10 HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts\11 HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts\12 HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts\13 HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts\14 HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts\15 HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts\16 HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts\17 HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts\18 HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts\19 HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts\1A HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts\1B HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts\1C HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\CYGWIN.DLL setup\b15.0\mounts\1D c: hd FAT 2047Mb 86% CP UN d: hd NTFS 2063Mb 63% CP CS UN PA FC e: net FAT 2047Mb 75% CP UN f: net NTFS 2055Mb 62% CP CS UN PA FC g: net FAT 2047Mb 82% CP UN h: net NTFS 2055Mb 67% CP CS UN PA FC r: cd N/A N/A g:\vol1\port\tpg217 /nusrc user textmode d:\netexpress\base /cobol user textmode d:\r7systems.old /port user binmode c:\cygwin\bin /usr/bin system binmode c:\cygwin\lib /usr/lib system binmode d:\bankmaster /bankmaster user textmode d:\r7systems /r7systems user binmode d:\download /download user binmode d:\copylib /copylib user textmode c:\cygwin / system binmode d:\temp /temp user textmode Found: c:\cygwin\bin\bash.exe Found: c:\cygwin\bin\cat.exe Found: c:\cygwin\bin\cpp.exe Found: c:\cygwin\bin\find.exe Found: c:\dos\find.exe Warning: c:\cygwin\bin\find.exe hides c:\dos\find.exe Found: c:\cygwin\bin\gcc.exe Found: c:\cygwin\bin\gdb.exe Found: c:\cygwin\bin\ld.exe Found: c:\cygwin\bin\ls.exe Found: c:\cygwin\bin\make.exe Found: c:\cygwin\bin\sh.exe 56k 2000/12/03 c:\cygwin\bin\cygbz21.0.dll - os=4.0 img=1.0 sys=4.0 "cygbz21.0.dll" v0.0 ts=2000/11/21 5:23 18k 2000/10/23 c:\cygwin\bin\cyggdbm.dll - os=4.0 img=1.0 sys=4.0 "cyggdbm.dll" v0.0 ts=2000/10/23 7:56 14k 2000/10/23 c:\cygwin\bin\cygintl.dll - os=4.0 img=1.0 sys=4.0 "cygintl.dll" v0.0 ts=2000/10/24 0:32 45k 2000/10/22 c:\cygwin\bin\cygjbig1.dll - os=4.0 img=1.0 sys=4.0 "cygjbig1.dll" v0.0 ts=2000/10/23 4:36 119k 2000/10/23 c:\cygwin\bin\cygjpeg6b.dll - os=4.0 img=1.0 sys=4.0 "cygjpeg6b.dll" v0.0 ts=2000/10/23 6:28 17k 2001/01/07 c:\cygwin\bin\cyghistory4.dll - os=4.0 img=1.0 sys=4.0 "cyghistory4.dll" v0.0 ts=2001/1/7 10:04 108k 2001/01/07 c:\cygwin\bin\cygreadline4.dll - os=4.0 img=1.0 sys=4.0 "cygreadline4.dll" v0.0 ts=2001/1/7 10:04 81k 2000/12/05 c:\cygwin\bin\cygitcl30.dll - os=4.0 img=1.0 sys=4.0 "cygitcl30.dll" v0.0 ts=2000/11/26 7:13 35k 2000/12/05 c:\cygwin\bin\cygitk30.dll - os=4.0 img=1.0 sys=4.0 "cygitk30.dll" v0.0 ts=2000/11/26 7:13 623k 2000/12/05 c:\cygwin\bin\cygtk80.dll - os=4.0 img=1.0 sys=4.0 "cygtk80.dll" v0.0 ts=2000/11/26 7:13 243k 2000/10/23 c:\cygwin\bin\cygtiff3.dll - os=4.0 img=1.0 sys=4.0 "cygtiff3.dll" v0.0 ts=2000/10/23 6:44 41k 2000/11/20 c:\cygwin\bin\cygXpm-noX4.dll - os=4.0 img=1.0 sys=4.0 "cygXpm-noX4.dll" v0.0 ts=2000/11/20 8:11 45k 2000/11/20 c:\cygwin\bin\cygXpm-X4.dll - os=4.0 img=1.0 sys=4.0 "cygXpm-X4.dll" v0.0 ts=2000/11/20 8:15 82k 2001/01/21 c:\cygwin\bin\cygform5.dll - os=4.0 img=1.0 sys=4.0 "cygform5.dll" v0.0 ts=2001/1/22 2:09 53k 2001/01/21 c:\cygwin\bin\cygmenu5.dll - os=4.0 img=1.0 sys=4.0 "cygmenu5.dll" v0.0 ts=2001/1/22 2:09 414k 2001/01/21 c:\cygwin\bin\cygncurses++5.dll - os=4.0 img=1.0 sys=4.0 "cygncurses++5.dll" v0.0 ts=2001/1/22 2:10 299k 2001/01/21 c:\cygwin\bin\cygncurses5.dll - os=4.0 img=1.0 sys=4.0 "cygncurses5.dll" v0.0 ts=2001/1/22 2:08 34k 2001/01/21 c:\cygwin\bin\cygpanel5.dll - os=4.0 img=1.0 sys=4.0 "cygpanel5.dll" v0.0 ts=2001/1/22 2:08 390k 2001/01/18 c:\cygwin\bin\cygtcl80.dll - os=4.0 img=1.0 sys=4.0 "cygtcl80.dll" v0.0 ts=2001/1/18 10:14 5k 2001/01/18 c:\cygwin\bin\cygtclpip80.dll - os=4.0 img=1.0 sys=4.0 10k 2001/01/18 c:\cygwin\bin\cygtclreg80.dll - os=4.0 img=1.0 sys=4.0 "cygtclreg80.dll" v0.0 ts=2001/1/18 10:14 163k 2001/02/03 c:\cygwin\bin\cygpng2.dll - os=4.0 img=1.0 sys=4.0 "cygpng2.dll" v0.0 ts=2001/2/4 2:51 49k 2001/02/03 c:\cygwin\bin\cygz.dll - os=4.0 img=1.0 sys=4.0 "cygz.dll" v0.0 ts=2001/2/4 2:05 615k 2001/01/31 c:\cygwin\bin\cygwin1.dll - os=4.0 img=1.0 sys=4.0 "cygwin1.dll" v0.0 ts=2001/1/31 20:38 Cygwin DLL version info: dll major: 1001 dll minor: 8 dll epoch: 19 dll bad signal mask: 19005 dll old termios: 5 dll malloc env: 28 api major: 0 api minor: 34 shared data: 3 dll identifier: cygwin1 mount registry: 2 cygnus registry name: Cygnus Solutions cygwin registry name: Cygwin program options name: Program Options cygwin mount registry name: mounts v2 cygdrive flags: cygdrive flags cygdrive prefix: cygdrive prefix cygdrive default prefix: build date: Wed Jan 31 10:08:38 EST 2001 shared id: cygwin1S3 --------------------------------------------------------------------------------------------------------------------------- This email message (including any attachment) is confidential and may be legally privileged. It is intended solely for the addressee. If you are not the addressee, you may not disclose it, copy it, distribute it or take or omit to take any action on foot of it. Any such act or omission is prohibited and may be unlawful. This message (including any attachment) is transmitted for discussion purposes only. It is protected by copyright laws and it has no other legal or contractual standing. ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. www.Kindlesystems.com ********************************************************************** -- Want to unsubscribe from this list? Check out: http://cygwin.com/ml/#unsubscribe-simple