Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: Killing subprocess in windows

by LanX (Sage)
on May 20, 2021 at 21:36 UTC ( #11132814=note: print w/replies, xml ) Need Help??


in reply to Re: Killing subprocess in windows
in thread Killing subprocess in windows

> instead of your unusual syntax, you can try to fork

could you please show me how? From the docs:

fork() creates a new process by duplicating the calling process.

I don't wanna replicate the Perl script but spawn a PS window.

> tail and grep for Windows

does this offer the -f option? I don't think so.

> is File::Tail usable on Windows ?

File::Tail seems overkill, and like the title suggests there might be problems on Win

get-content -wait is a built-in in all modern Win versions

> You can also use Win32::Process to create and kill the subprocess.

That's a very good idea, thanks! :)

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^3: Killing subprocess in windows
by eyepopslikeamosquito (Bishop) on May 20, 2021 at 23:35 UTC

      Yes, i know you don’t want to spawn…

      But consider something like this:

      use strict; use warnings; use threads; use MCE::Hobo; my $hobo = MCE::Hobo->create( sub { …; }); my $pid = $hobo->pid(); # $hobo->join();

      Update:

      «I though about sending a 'kill', but Perl doesn't seem to give me the PID.»

      Now you have one to kill.

      «The Crux of the Biscuit is the Apostrophe»

Re^3: Killing subprocess in windows
by Discipulus (Abbot) on May 21, 2021 at 07:04 UTC
    Hello LanX,

    > (about fork) I don't wanna replicate the Perl script but spawn a PS window.

    You are already forking!

    From system

    > Does exactly the same thing as exec, except that a fork is done first and the parent process waits for the child process to exit.

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
      that's the inner implementation.°

      just show me how to do it with fork and you'll see how complicated it is.

      update

      °) and I wouldn't be too sure it's ported the same way to windows.

      IIRC is fork implemented with threads there, so there might be issues.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11132814]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2021-10-24 22:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (89 votes). Check out past polls.

    Notices?