1:         common/sig/whoami
   2:         character*6 whoami
   3:         integer fork, getpid, wait, tick
   4:         external trap
   5: 
   6:         call signal(2, trap, -1)
   7:         call signal(3, trap, -1)
   8:         call signal(6, trap, -1)
   9:         call signal(8, trap, -1)
  10:         call signal(15, trap, -1)
  11: 
  12:         tick = 1
  13:         id = fork()
  14:         if (id .eq. 0) then
  15:             whoami = "child"
  16:             write(*,*) "child:", getpid()
  17:             call flush(6)
  18:    10       call sleep(1)
  19:             write(*,'(1x,i2,$)') tick
  20:             call flush(6)
  21:             tick = tick + 1
  22:             goto 10
  23:         else
  24:             whoami = "parent"
  25:             call sleep(5)
  26:             write(*,*) "\nparent:", id
  27:             call flush(6)
  28:             istat = kill(id, 15)
  29:             write(*,*) "\nkill status:", istat
  30:             call flush(6)
  31:             iwait = wait(isw)
  32:             write(*,*) iwait, isw
  33:         endif
  34:         end
  35: 
  36:         subroutine trap(num)
  37:         common/sig/whoami
  38:         character*6 whoami
  39:         write(*,*) "\ntrap:", whoami, num
  40:         stop
  41:         end
Last modified: 1983-05-20
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 544
Valid CSS Valid XHTML 1.0 Strict