Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: Killing subprocess in windows

by LanX (Saint)
on May 20, 2021 at 21:36 UTC ( [id://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 (Archbishop) 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 (Canon) 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?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-04-24 21:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found