This script always ensures that the 'forked' child process is always
running:

######

REBOL[]

clib: make library! %/lib/libc.so.6

getpid: make routine!

 return: [ integer! ]
] clib "getpid"

fork: make routine!

 return: [ integer! ]
] clib "fork"

perror: make routine!

 str [ string! ]
 return: [ long ]
] clib "perror"

waitpid: make routine! [
 pid [ integer! ]
 status [ integer! ]
 options [ integer! ]
 return: [ integer! ]
] clib "waitpid"

forever [

 childPid: fork

 either equal? 0 childPid [
  ; Child
  wait 1
  print [ "[" getpid "] Child start" now/time ]

  ; perform logic i.e.

  free clib

  quit
 ] [
  ; Parent
  print [ "[" getpid "] Parent Waitpid" now/time ]
  rc: reform [ waitpid childPid 0 0 ]
  if equal? -1 rc

   perror "function [waitpid]"
 free clib
quit
  ]
 ]

]

free clib

quit 0


####

Phil




-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to