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

Re: Check for another program availability (Running External Processes on Unix and Windows References)

by eyepopslikeamosquito (Archbishop)
on Apr 12, 2021 at 09:57 UTC ( [id://11131128]=note: print w/replies, xml ) Need Help??


in reply to Check for another program availability

Robustly running external processes is a tricky and subtle business.

Having laboured for years at the C level on cross-platform Unix/Windows code -- while lovingly studying the collected works of Mark Russinovich, Jeffrey Richter and the legendary W Richard Stevens (who tragically died way too young at 48) -- I am painfully aware of how differently Windows and Unix deal with processes under the covers. For example, Unix uses signals for IPC while Windows does not and command line parsing is completely different. Worse, I have no clue about (and no interest in) the subtleties of running external processes on Dec VMS, Classic Mac OS, and other obscure OSes that Perl supports.

Accordingly, to keep my code simpler and easier to test and troubleshoot (while being correct for each OS), I usually prefer to use separate code paths for Windows and Unix code that runs external commands (a crude example of this approach can be found in Timing and timing out Unix commands and Re: Timing Windows commands). I also worry about the correctness of a cross-platform abstraction and especially the difficulty of troubleshooting bugs. I might add that I've always applauded Perl for allowing me to easily write Unix-specific code and Windows-specific code when I want to.

So, given your reply here, my advice is to write your Perl code that runs external processes to work on Unix only, test it on Unix only, and clearly document that assumption. I don't think you need worry about differences between different Unix flavours (e.g. Linux vs AIX), at least I'm not aware of any gotchas in this area.

Update: BTW, this reply (in a long debate on the history of Windows NT vs Unix) mentions the real reason why Windows does not have Unix-like signals, and further notes the vast gulf between Windows CreateProcess and Unix fork/exec.

References Added Later

These two are excellent:

Other references:

See also:

  • Comment on Re: Check for another program availability (Running External Processes on Unix and Windows References)
  • Select or Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (2)
As of 2024-04-24 17:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found