Hi again.
This has to do with my yesterday's problem, but it's even a bit more complicate ;-)
My script.pl opens an application.exe in the background with open3, but as it is given a pipe to logger.bat (look at the code:
$pid=open3(NULL,\*NULL,\*NULL, "application.exe 2>&1 | logger.bat");
it doesn't return the PID of application.exe to $pid, but the PID of CMD.exe, which is opened automatically for running the pipe and logger.bat.
So here's the problem:
1. I need to know the PID of application.exe - but: there are several instances of application.exe running at the same time, so looking for application.exe in the Win32::Process names doesn't make sense.
2. My script.pl is started over srvany.exe as a Win32 service. So I'll start it with "net start script" and stop it with "net stop script". The problem is, I have to kill application.exe before my script is killed. In other words: killing my script, will leave the application.exe running.
So I need to catch the "net stop" within my script.pl, so that I can kill application.exe before script.pl exits.
I tried so many ways now, but I don't think that there is another possibility to run application.exe the way I want than the way I have given in the piece of code.
(Yes, I tried out all the things you gave me yesterday. Thanks again for that.)
One possibility could be, that application.exe looks that his parent, my script.pl, is running, and if not, it will quit. But I'd prefer not to change the sources of application.exe.
Any ideas?
Thorsten
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.