Thread Prozess Starten und PID speichern: ohne open (8 answers)
Opened by bloonix at 2006-06-03 17:51

pq
 2006-06-03 19:31
#66978 #66978
User since
2003-08-04
12208 Artikel
Admin1
[Homepage]
user image
wieso geht fork nicht? der prozess muss halt nur ohne shell
gestartet werden:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
$ cat forked.pl
#!/usr/bin/perl
use strict;
use warnings;
open FH, ">forked.dat" or die $!;
print FH "forked $$\n";
close FH;
print STDERR "This should not appear ($$)\n";

$ perl -wle'
if (my $pid = fork()) {
 print "parent $$ forked $pid";
}
elsif (defined $pid) {
 close STDERR;
 exec qw(perl forked.pl);
}
'
parent 29747 forked 29748

$ cat forked.dat
forked 29748
\n\n

<!--EDIT|pq|1149348750-->
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. -- Damian Conway in "Perl Best Practices"
lesen: Wiki:Wie frage ich & perlintro Wiki:brian's Leitfaden für jedes Perl-Problem

View full thread Prozess Starten und PID speichern: ohne open