Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: print or die?

by robby_dobby (Friar)
on Mar 14, 2014 at 13:21 UTC ( #1078328=note: print w/replies, xml ) Need Help??

in reply to print or die?

Hello molecules,

I think there may be a better way to do this (other more knowledgeable monks here would chime in) - but have you looked at sigtrap pragma? Adding a die to every print seems kludgy to me.

Normally, when you have a full disk, you'd encounter a ENOSPC on *nix systems. If you're specifically looking for this signal, you can install an handler to trap it and break out. Otherwise, you can use a 'catchall' untrapped handler on other signals (Do note that this can modify behaviour on other signals that are supposed to do their work :-)).

There may well be a better way to do this...

Replies are listed 'Best First'.
Re^2: print or die?
by dave_the_m (Prior) on Mar 14, 2014 at 19:04 UTC
    ENOSPC is a return value from a system call, not a signal; so you can't trap it with a signal handler. (The only exception to this being SIGPIPE when writing to a closed pipe or socket.)


      Thank you - I was waffling between signals and errnums. My thinking was, ENOSPC is an errnum from a syscall (usually write) and if print used write under the hood, we would see this error code on a full disk.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1078328]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2018-02-18 01:52 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (250 votes). Check out past polls.