
BorisE
Novice
May 18, 2008, 10:59 AM
Post #3 of 3
(1145 views)
|
|
Re: [bongu] does anybody know what this is doing?
[In reply to]
|
Can't Post
|
|
Looks like a forking code example (Hope I'm not stating the obvious here). The program should run normally as far as fork at which point the process duplicates itself, both processes continuing from that point. In the parent process "fork" returns the PID of the child, in the child process I think it returns undef. By testing $pid it determines which branch it took, the child branch writes some stuff to a pipe and the parent branch is probably meant to read it. I've no idea at all what the fcntrl and chmod are for. There's probably a good reason its laid out like that but personally I'd prefer to do something like my $pid=fork(); unless ($pid) { # Do child stuff exit; } # Do parent stuff here BTW I probably shouldn't post in ADVANCED yet but I found this with a forum search, I'm actually searching for advice on passing file handles to subroutines.
(This post was edited by BorisE on May 18, 2008, 11:01 AM)
|