Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re^2: Perl wait vs Unix ksh wait (spawn)

by jettero (Monsignor)
on Oct 31, 2007 at 18:20 UTC ( #648319=note: print w/replies, xml ) Need Help??

in reply to Re: Perl wait vs Unix ksh wait (spawn)
in thread Perl wait vs Unix ksh wait

That seems like a perl limitation, not a unix one, since there are plenty of ways to do this in perl and without.

For whatever reason, you have to use fork or modules (like IPC::Open3 or whatever) in unix. Actually, why does system(1,$cmd) work at all? I don't see that documented. It's possible I'm blind. I'm cutting down on coffee.

UPDATE: I still don't see how that's a unix problem, rather than a perl one; but I guess I understand your animosity/reciprocity.

UPDATE2 (nov 1st): Your example (in a sibling post) also seems intentionally complex...

use strict; use warnings; use IPC::Open3; use Data::Dumper; my ($w,$r,$e, @pids); push @pids, open3($w,$r,$e, qw(ls -al)); push @pids, open3($w,$r,$e, qw(ls -al)); push @pids, open3($w,$r,$e, qw(borked mang)); # tye commented privately that I seem to misunderstand open3, so I jus +t thought # I'd mention that I'm perfectly aware I'm screwing up the file handle +s both by # reusing them and failing to close them. This is just an example... + Perhaps it's # because the ls doesn't print to stdout? I suppose that isn't the sa +me as system(). # *shrug* my @ret = map {[waitpid($_,0) => $?]} @pids; print "", Dumper(\@ret), "\n";


Replies are listed 'Best First'.
Re^3: Perl wait vs Unix ksh wait (Unix)
by tye (Sage) on Oct 31, 2007 at 18:51 UTC

    Sorry, it is long-standing tradition that, whenever anyone asks a question where the answer in Win32 is harder than the answer in Unix, for several Unix lovers to make jokes about "get a Real™ operating system". I assumed, based on the Golden Rule, that they must want this same treatment when the situation is reversed. However, it appears to often result in several Unix lovers getting their panties in a wad when it is pointed out that their favorite operating system is not perfect, in fact, in some ways inferior to some other operating system (especially if that operating system is from a particular vendor, it seems).

    Oh well, not everybody has a sense of humor about all subjects.

    In my experience, the use of fork or some module will be quite a bit more complex than what I wrote and is likely to be buggy (and is very unlikely to do the nice stuff system(1,...) does with the pipe to the child so the parent can distinguish 'exec' failing from the launched program failing).

    Update: Note that I don't replicate the childish part of the tradition of mispelling the name of the operating system to make fun of it. (:

    - tye        

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://648319]
[Corion]: Discipulus: Ouch ... staff cuts are never good, but having to hunt for work isn't great either, especially with a family...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2018-05-23 21:23 GMT
Find Nodes?
    Voting Booth?