Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird processor usage, when redirecing IO to /dev/null #62

Open
briandfoy opened this issue Jul 10, 2023 · 1 comment
Open

Weird processor usage, when redirecing IO to /dev/null #62

briandfoy opened this issue Jul 10, 2023 · 1 comment
Labels

Comments

@briandfoy
Copy link
Owner

briandfoy commented Jul 10, 2023

This ticket was imported from rt.cpan.org 43780


Hi'

I am targeting a simple perl loop, in which I with ssh->cmd will execute a command on a remote host. This code should run in the back ground on the mother host.

The following simple code shows my observation.

use Net::SSH::Perl;

$host = Net::SSH::Perl->new("remotehost");
$host->login();

while (1) {
    print `date`;
    ($out, $err, $exit) = $host->cmd("sleep 10");
}

Now, call the code test.pl and run "./test.pl". Command "top" running in another shell on the mother host does not show anything suspicious. Now I would like to have the code running in the background and thus I do "./test.pl </dev/null 1>/dev/null 2>/dev/null &". Now the "top" command shows my little program eating up one full processor. This puzzles me very much indeed and I am speculating, if this is a bug or a feature.

Thanks for any help in advance.

Best regards.

Thomas.

@briandfoy
Copy link
Owner Author

from schwigon@cpan.org


On Mon Mar 02 14:31:05 2009, ki11er_bob@yahoo.dk wrote:

"./test.pl".
"./test.pl </dev/null 1>/dev/null 2>/dev/null &".
Now the "top" command shows my little program eating up one full
processor.

Not the "to /dev/null" is an issue, but the "from /dev/null".

It tries to read from STDIN, maybe during its filehandle hijacking.
You can see the shell stopping it when you don't feed its stdin.

./test.pl 1>/dev/null 2>/dev/null &

The cpu usage in such a situation is normal, similar to
a process searching for its lost tty.

The way I understand Net::SSH::Perl so far I don't think
this gets resolved.

Kind regards,
Steffen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant