Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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


In reply to Re: Check for another program availability by eyepopslikeamosquito
in thread Check for another program availability by hrcerq

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

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












    Results (68 votes). Check out past polls.

    Notices?