bt101 has asked for the wisdom of the Perl Monks concerning the following question:
However it does not give me the correct pid of the sleep program:#!/usr/bin/perl use strict; use warnings; my $pid = fork; if ((defined $pid) && ($pid == 0)) { exec("sleep 30 >> /dev/null 2>&1 &"); exit; } print "child pid [$pid]\n";
How can I a launch a program and get its pid?$ perl tst.pl child pid [23367] $ ps ax | grep sleep 23368 pts/7 S 0:00 sleep 30 23371 pts/7 S+ 0:00 grep --colour=auto sleep
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How do you launch a background process and get pid?
by graff (Chancellor) on Apr 18, 2016 at 09:24 UTC | |
by bt101 (Acolyte) on Apr 18, 2016 at 16:33 UTC | |
by afoken (Chancellor) on Apr 18, 2016 at 17:12 UTC | |
|
Re: How do you launch a background process and get pid?
by Anonymous Monk on Apr 18, 2016 at 03:48 UTC | |
by Anonymous Monk on Apr 18, 2016 at 03:51 UTC |