in reply to exec creates two processes.. how to kill them?

Rather than telling you how to find the pids and kill them, I'm choosing to describe a better way to "cat" the device, that requires no extra pids.

open my $in, "/dev/urandom" or die "couldn't open random: $!"; open my $out, ">a_file.bin" or die "couldn't open output file: $!"; eval { alarm 1; my $buf; read $in, $buf, 1024 or die "error reading: $!"; my $orig = select $out; local $| = 1; select $orig; print $out $buf; }; close $in; close $out;

That was from memory, so if I got something wrong, don't sue me or anything. I also think you can make it a lot better than what I put above, but I also think all the right stuff is in there so you can cook from it with little trouble.

-Paul

Replies are listed 'Best First'.
Re^2: exec creates two processes.. how to kill them?
by santosh_sugur (Initiate) on Jan 10, 2008 at 16:54 UTC
    Thank you Paul. That worked just as you had typed. I also learnt a lot of things from that small bit of code. This is my first experience here.. and its really been enlightening :)