suaveant has asked for the wisdom of the Perl Monks concerning the following question:

This isn't exactly a perl question, but usually when I've wanted to do this it was a from a perl script or to a perl script...

Is there a way to suspend/continue a process from within perl or on the command line? Like ctrl-Z in bash?

                - Ant
                - Some of my best work - Fish Dinner

Replies are listed 'Best First'.
Re: Suspending a process (slighty OT)
by wog (Curate) on Sep 23, 2001 at 23:00 UTC
    Typing ctrl-Z at the tty usually just sends the 'TSTP' signal process. You can do this yourself with kill:

    kill TSTP => $some_proccess_id;

    ... you should also be able to catch this signal from a perlscript and do some processing before stopping your process, or just to make your process not be stopable this way. A process can also be stopped with the 'STOP' signal which cannot be caught, which you'd need to use if you wanted to stop your process while still catching the 'TSTP' signal.

    Restarting a process can be done by sending the 'CONT' signal to process.

    Obviously, you can also do these things using the kill command on the command line.

    update: Of course, all this advice is rather UNIX-specific.

      From a Windows perspective... just use Win32::Process. $ProcessObj->Suspend(); and  $ProcessObj->Resume(); should do exactly what you wish to do.
        I could be wrong, but I think that the Suspend and Resume methods only work on objects created by Win32::Process::Create().

        Simon Flack ($code or die)
        $,=reverse'"ro_';s,$,\$,;s,$,lc ref sub{},e;$,
        =~y'_"' ';eval"die";print $_,lc substr$@,0,3;