DEV Community

Discussion on: GNU timeout annoyed me so I replaced it; or an extremely simple introduction to fork() and signal handling in perl

Collapse
 
ap profile image
Aristotle Pagaltzis
@ARGV == 2 or die $USAGE;

This is needlessly restrictive. It should be >= instead of ==. That way you can avoid running the given command through the shell.

system @command;

It may be useful to use system { $command[0] } @command here instead, which will ensure the command is never run under shell. This loses a bit of convenience if the user did want to run the command under shell, but prepending sh -c ... to the arguments is no big deal and this keeps the program from containing a hidden “oops, you got shell when you didn’t mean to” trap.

But this is more subjective than the other change.

Thread Thread
 
sbakker profile image
Steven Bakker

Good suggestions, thanks. I quickly threw this together to test the signal mechanism, didn't pay attention to the arguments that much.