Background child with PID under Windows

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Paradox4
    New Member
    • Jan 2009
    • 1

    Background child with PID under Windows

    Hi,

    I'm converting an existing Perl script from UNIX to Windows XP.

    This script calls another Perl script in the background using backticks and ampersand (`x_child.pl ... &`).
    The child script acts as a timeout check for the parent and will kill it if it's stuck for too long.
    Eventually, the parent will also kill the child script - using the shell's `ps -ef | grep x_child.pl ...` to locate the child's PID.

    I need to replicate this behaviour under windows but wasn't able to find the tools:

    1. using 'system(1, "perl x_child.pl...") ' the script runs in the background, but I can't get it's PID.

    2. using 'tasklist' doesn't seem to get the program's arguments to enable identifying a specific instance, or even the script's name (only 'perl.exe').

    3. using 'open(GET_PID, "perl x_child.pl ...|")' I can communicate with the process and have it send back it's PID, but I can't have it run in the background.

    ('...' meaning script arguments)

    Any ideas ?
  • numberwhun
    Recognized Expert Moderator Specialist
    • May 2007
    • 3467

    #2
    Originally posted by Paradox4
    Hi,

    I'm converting an existing Perl script from UNIX to Windows XP.

    This script calls another Perl script in the background using backticks and ampersand (`x_child.pl ... &`).
    The child script acts as a timeout check for the parent and will kill it if it's stuck for too long.
    Eventually, the parent will also kill the child script - using the shell's `ps -ef | grep x_child.pl ...` to locate the child's PID.

    I need to replicate this behaviour under windows but wasn't able to find the tools:

    1. using 'system(1, "perl x_child.pl...") ' the script runs in the background, but I can't get it's PID.

    2. using 'tasklist' doesn't seem to get the program's arguments to enable identifying a specific instance, or even the script's name (only 'perl.exe').

    3. using 'open(GET_PID, "perl x_child.pl ...|")' I can communicate with the process and have it send back it's PID, but I can't have it run in the background.

    ('...' meaning script arguments)

    Any ideas ?
    Unfortunately, I am not really sure where to go with this. But, being a Unix guy and not a Windows guy, I can say that the 'ps' command on windows probably won't do you much good. Windows handles its processes differently and I don't know how to identify them with Perl. You may want to scour the internet for "perl win32 programming" or something like that.

    Regards,

    Jeff

    Comment

    Working...