Subject: | Shell hangs on logout |
$ ./daemon start
$ logout
SSH connection hangs.
I'm pretty certain its because STDIN was not delt with.
http://perldoc.perl.org/perlipc.html#Complete-Dissociation-of-Child-
from-Parent has a bit more info.
Code from my version (though there's probably a better way of handling
this):
sub gd_redirect_output
{
my $self = shift;
return if $self->{gd_foreground};
my $logname = $self->gd_logname;
my $p = $self->{gd_logpriority} ? "-p $self->{gd_logpriority}" :
"";
close(STDIN);
close(STDOUT);
close(STDERR);
open(STDIN, '/dev/null') or die "Can't read /dev/null: $!";
open(STDOUT, "|logger $p -t '$logname'") or die "redirect STDOUT
-> STDERR: $!";
open(STDERR, "|logger $p -t '$logname'") or (print "could not
open stderr: $!" && exit(1));
}