Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^7: Doing every X seconds

by anonymized user 468275 (Curate)
on Aug 07, 2018 at 13:37 UTC ( [id://1219991]=note: print w/replies, xml ) Need Help??


in reply to Re^6: Doing every X seconds
in thread Doing every X seconds

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^8: Doing every X seconds
by Corion (Patriarch) on Aug 07, 2018 at 13:49 UTC

    It's not really uncommon to run processes under a strict ulimit limit, reducing the number of processes a user account can have running. This usually protects against runaway processes.

    You can easily reproduce the problem by using ulimit -u 64 and run any kind of forkbomb.

Re^8: Doing every X seconds
by haukex (Archbishop) on Aug 07, 2018 at 14:49 UTC
    if you spend six months writing code that caters for porting to some non-forkable environment

    That's not what we're talking about. It's a single line of code.

    And if you were to ask if I would spend the literally 7 seconds it takes to type defined($pid) or die "fork failed: $!"; to save my employer the potential costs of a mysterious failure sometime in the future by replacing it with an error message, even on platforms where fork is supported, then yes, I would! I'm taking your continued disagreement to mean that you wouldn't. Although I disagree with that, I can't stop you from providing your employer with whatever code you like - but that's not what we're talking about either.

    We're talking about providing a piece of code to help a stranger, and potentially many other future visitors of this site. In your posts, you showed the usage of fork without a check for an error or a mention that you've omitted the check and why. You can't be certain that on any of the systems where this code might be run in the future, fork will never return undef.

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re^8: Doing every X seconds
by jeffenstein (Hermit) on Aug 07, 2018 at 16:02 UTC

    Fork can fail for lots of different reasons. For example: not enough swap to hold two copies of the process, you've reached the max process for your user or globally, not enough physical memory to complete the fork, you got a signal during the fork call, etc.

    It seem naive to me to think that an error can't happen; it's better to die if it does happen than to continue on with possible corruption. If you don't like the aesthetic, then write a wrapper that dies on errors, so you can present clean code.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-19 05:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found