bug-bash
[Top][All Lists]
Advanced

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

behavior of ctrl-c handler changes after 'wait' is used


From: Matt Chapman
Subject: behavior of ctrl-c handler changes after 'wait' is used
Date: Fri, 12 Jan 2001 15:44:52 -0800 (PST)

Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DSHELL -DHAVE_CONFIG_H  -D_FILE_OFFSET_BITS=64  -I.  -I. 
-I./lib -I/usr/local/include -g
uname output: Linux genome.synopsys.com 2.2.16-22 #1 Tue Aug 22 16:49:06 EDT 
2000 i686 unknown
Machine Type: i686-pc-linux-gnu

Bash Version: 2.03
Patch Level: 0
Release Status: release

Description:
        On Linux (Redhat 6.2), the behavior of the ctrl-c (SIGINT)
        handler changes after 'wait' is used.  Before wait is used,
        ctrl-c is passed to the child process.  After wait is used,
        ctrl-c causes the bash shell to exit, which orphans the child
        process.

Repeat-By:
        Execute the following script to reproduce the behavior.

--------------- cut here -------------
#/bin/sh

cat > ctrlc.c <<EOF
#include <stdio.h>
void *sighandler(int sig) {
  if ( sig == 3 ) exit(0);
  printf(" ctrl-c ");
  fflush(stdout);
}
main() {
  signal(2, sighandler);  
  signal(3, sighandler);
  while ( 1 ) {
      printf("x");
      fflush(stdout);
      sleep(1);
  }
}
EOF

cc ctrlc.c -o ctrlc

echo Hit ctrl-c to test, ctrl-4 to exit
./ctrlc
echo ""
echo ctrlc done 1
echo ""

ls -ltr /etc /lib > /dev/null &
wait $!

echo Bug: hitting ctrl-c now will exit the shell instead of ctrlc
./ctrlc
echo ""
echo ctrlc done 2
echo ""

rm ctrlc ctrlc.c
--------------- cut here -------------

Fix:




reply via email to

[Prev in Thread] Current Thread [Next in Thread]