in reply to Re: How to terminate a childprocess by press Ctrl_c
in thread How to terminate a childprocess by press Ctrl_c

This node falls below the community's threshold of quality. You may see it by logging in.
  • Comment on Re^2: How to terminate a childprocess by press Ctrl_c

Replies are listed 'Best First'.
Re^3: How to terminate a childprocess by press Ctrl_c
by kyle (Abbot) on Oct 25, 2007 at 16:19 UTC

    First, contrary to what you might be used to elsewhere, posting code here works best if it's in <code> tags.

    #!/usr/bin/perl #print "PID=$$\n"; my $child=fork(); die "Can't fork:$!" unless defined $child; if($child>0) { print "Parent process:PID=$$, child=$child\n"; } else { my $ppid=getppid(); print "Child process: PID=$$,parent=$ppid\n"; }

    The reason this doesn't work for you, basically, is you're on Windows. On that platform, fork is faked using threads (and getppid is not implemented). This probably also means that signals won't work the way I'd otherwise expect them to, so my previous advice won't help much either. My experience with Perl on Windows is minimal, so I don't think I'll be able to help you with this at all.

    A reply falls below the community's threshold of quality. You may see it by logging in.