in reply to Re: getting a child's process ID
in thread getting a child's process ID

If Perl finds something in the command line for exec or system that it can't interpret (like a redirection), it will invoke the shell to parse the command. This is what's happening here.

As a solution, you could either do the redirect yourself by reopening STDERR to the file or restructure your approach so that you get the correct PID into the appropriate place.

Replies are listed 'Best First'.
Re^3: getting a child's process ID
by markdibley (Sexton) on Jan 09, 2015 at 14:02 UTC
    Thanks for the reply. The idea is to make this code independent of what it is running. It seems every day my argument for using perl gets weaker and weaker.

      If you don't want Perl to insert a shell between your program and the child process, then you'll have to filter out all the redirection etc. yourself.

      The alternative is to restructure your process in such a way that it always expects two processes.

      As you haven't told us much about your problem, I can't really help you here. Maybe you want to post a new thread via SoPW where you describe the actual problem you're trying to solve. Then maybe somebody can propose alternatives that allow you to accomplish your goal.