| 29 | GLOBAL_SIGCHLD_RECEIVED = 1 |
| 30 | |
| 31 | def main (): |
| 32 | signal.signal (signal.SIGCHLD, signal_handler) |
| 33 | pid, fd = pty.fork() |
| 34 | if pid == 0: |
| 35 | os.write (sys.stdout.fileno(), 'This is a test.\nThis is a test.') |
| 36 | time.sleep(10000) |
| 37 | nonblock (fd) |
| 38 | tty.setraw(fd) #STDIN_FILENO) |
| 39 | print 'Sending SIGKILL to child pid:', pid |
| 40 | time.sleep(2) |
| 41 | os.kill (pid, signal.SIGKILL) |
| 42 | |
| 43 | print 'Entering to sleep...' |
| 44 | try: |
| 45 | time.sleep(2) |
| 46 | except: |
| 47 | print 'Sleep interrupted' |
| 48 | try: |
| 49 | os.kill(pid, 0) |
| 50 | print '\tChild is alive. This is ambiguous because it may be a Zombie.' |
| 51 | except OSError as e: |
| 52 | print '\tChild appears to be dead.' |
| 53 | # print str(e) |
| 54 | print |
| 55 | print 'Reading from master fd:', os.read (fd, 1000) |
| 56 | |
| 57 | |
| 58 | |