Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Check for another program availability

by eyepopslikeamosquito (Bishop)
on Apr 12, 2021 at 09:57 UTC ( #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 huge gulf between Windows CreateProcess and Unix fork/exec.

References Added Later

  • Comment on Re: Check for another program availability

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2021-06-15 06:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (67 votes). Check out past polls.

    Notices?