in reply to Did ChatGPT do a good job?
What do you think? Any other problems i didn't catch?
Two things:
- The detection of the child process is bogus. In Perl, ($pid == 0) evaluates to true if $pid is undefined. So, if forking fails, then the parent will call doWork before exiting normally. elsif (!defined $pid) will never be evaluated.
- $SIG{CHLD} is defined only after the round of forks. If a child dies before the sub is defined, then it won't be restarted.