mirror of
https://github.com/webmin/webmin.git
synced 2026-02-03 06:03:28 +00:00
Fix to steal if needed and don't fail unless term wanted #2595
This commit is contained in:
@@ -321,12 +321,25 @@ elsif (defined &linux_openpty &&
|
||||
if (defined(&close_controlling_pty)) {
|
||||
&close_controlling_pty();
|
||||
}
|
||||
setsid(); # create new session group
|
||||
my $ctty_arg = 0; # must be writable scalar
|
||||
ioctl($ttyfh, $TIOCSCTTY, $ctty_arg) # controlling tty
|
||||
or &error("TIOCSCTTY failed: $!");
|
||||
# Child must not hold the master end
|
||||
close($ptyfh);
|
||||
my $need_ctty = $ENV{'TERM'} ? 1 : 0;
|
||||
setsid() # create new session group
|
||||
or do {
|
||||
# don't fail, just log it if we have a terminal
|
||||
&error_stderr("setsid failed: $!")
|
||||
if ($need_ctty);
|
||||
};
|
||||
close($ptyfh); # child must not hold master
|
||||
my $ctty_arg = 0; # try normal attach
|
||||
ioctl($ttyfh, $TIOCSCTTY, $ctty_arg) or do {
|
||||
$ctty_arg = 1; # try force attach
|
||||
ioctl($ttyfh, $TIOCSCTTY, $ctty_arg)
|
||||
or do {
|
||||
# don't fail, just log it if we have a
|
||||
# terminal
|
||||
&error_stderr("TIOCSCTTY failed: $!")
|
||||
if ($need_ctty);
|
||||
}
|
||||
};
|
||||
|
||||
# Turn off echoing, if we can
|
||||
eval "use IO::Stty";
|
||||
|
||||
Reference in New Issue
Block a user