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)) {
|
if (defined(&close_controlling_pty)) {
|
||||||
&close_controlling_pty();
|
&close_controlling_pty();
|
||||||
}
|
}
|
||||||
setsid(); # create new session group
|
my $need_ctty = $ENV{'TERM'} ? 1 : 0;
|
||||||
my $ctty_arg = 0; # must be writable scalar
|
setsid() # create new session group
|
||||||
ioctl($ttyfh, $TIOCSCTTY, $ctty_arg) # controlling tty
|
or do {
|
||||||
or &error("TIOCSCTTY failed: $!");
|
# don't fail, just log it if we have a terminal
|
||||||
# Child must not hold the master end
|
&error_stderr("setsid failed: $!")
|
||||||
close($ptyfh);
|
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
|
# Turn off echoing, if we can
|
||||||
eval "use IO::Stty";
|
eval "use IO::Stty";
|
||||||
|
|||||||
Reference in New Issue
Block a user