in reply to Re^3: System call constantly dying
in thread System call constantly dying

As I mentioned this is to test a filter driver, so I need to make the OS calls with system as they are checked differently than calls made within Perl; and really that is what I need to test. Things like the chmod example you mention are part of the test, to make sure the filter captures and does not barf on things like a chmod call on a directory. So, yes, it is testing and checking that certain operations work as hoped for.
I should do better with the OS dependency and group better, honestly though this script is much cleaner than the one I inherited, and its about 33% smaller than the original one as well. More cleanup on the OS stuff is on my list, I still have no idea why the System calls are suddenly acting up, but at least I can get by with them for now.
Thanks!

Replies are listed 'Best First'.
Re^5: System call constantly dying
by graff (Chancellor) on Jul 31, 2008 at 03:44 UTC
    I don't really know what a "filter driver" is, so I still don't understand the rationale for using system calls where perl built-ins are available for the same operations. No big deal, whatever.

    In any case, I wonder whether you may have missed the point of the earlier reply from almut:

    ... [system()] returns the exit code (return value of the wait call) of the called program, which is typically zero upon success...

    What that means is that a statement like this:

    system( $some_shell_command ) or die "bad news..."
    will actually cause the script to die when the system() call succeeds, because a return value of zero (false) from system() means that there was no error indicated in the exit status of the command. A less confusing idiom for doing this sort of error trapping with system() goes like this:
    $failed = system( $some_command ); die "bad news..." if ( $failed );