We are writing a test script as part of a porting effort. We need to perform the following:
Open a program and
1. read its STDOUT
2. calculate its system time
3. calculate its max memory
4. kill it if the script is Control-C'd
Here are the caveats: it has to be Unix/Win portable and can not use any non-core modules.
So, we use open(PROG,"pogname|") to open the program with a handle to its stdout. We install a signal-handler to deal with keyboard interupts. Fine. But how do we kill a program started by 'open' from the signal handler? Simply closing the filehandle is not enough.
To get the system time, we use 'times' as such:
($user,$system,$cuser,$csystem) = times;
It seems to me that the program started with 'open' should be our child, but $cuser & $csystem are zero. Does this only work when you have forked a child?
As for the max memory issue, I could scan the ps table, but this is not portable. I am at a loss here.
I know that this is actually several questions. I am also painfully aware that there is no easy answer, but I will be happy to consider any advise you might have to offer.
In reply to Portable Process Control by scmason
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |