mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-29 05:18:00 +00:00
tty02: open a slave tty with O_NOCTTY
Signed-off-by: Andrey Vagin <avagin@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
e6bd325845
commit
a943071e44
@ -5,7 +5,6 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <signal.h>
|
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
@ -13,11 +12,6 @@
|
|||||||
const char *test_doc = "Check a non-controling terminal";
|
const char *test_doc = "Check a non-controling terminal";
|
||||||
const char *test_author = "Andrey Vagin <avagin@openvz.org>";
|
const char *test_author = "Andrey Vagin <avagin@openvz.org>";
|
||||||
|
|
||||||
static void sighup_handler(int signo)
|
|
||||||
{
|
|
||||||
test_msg("SIGHUP is here\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char ** argv)
|
int main(int argc, char ** argv)
|
||||||
{
|
{
|
||||||
int fdm, fds;
|
int fdm, fds;
|
||||||
@ -26,8 +20,6 @@ int main(int argc, char ** argv)
|
|||||||
|
|
||||||
test_init(argc, argv);
|
test_init(argc, argv);
|
||||||
|
|
||||||
signal(SIGHUP, sighup_handler);
|
|
||||||
|
|
||||||
setsid();
|
setsid();
|
||||||
|
|
||||||
fdm = open("/dev/ptmx", O_RDWR);
|
fdm = open("/dev/ptmx", O_RDWR);
|
||||||
@ -41,17 +33,12 @@ int main(int argc, char ** argv)
|
|||||||
slavename = ptsname(fdm);
|
slavename = ptsname(fdm);
|
||||||
|
|
||||||
/* set up a controlling terminal */
|
/* set up a controlling terminal */
|
||||||
fds = open(slavename, O_RDWR);
|
fds = open(slavename, O_RDWR | O_NOCTTY);
|
||||||
if (fds == -1) {
|
if (fds == -1) {
|
||||||
err("Can't open a slave pseudoterminal %s", slavename);
|
err("Can't open a slave pseudoterminal %s", slavename);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ioctl(fds, TIOCNOTTY)) {
|
|
||||||
err("Unable to detach a terminal");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
test_daemon();
|
test_daemon();
|
||||||
test_waitsig();
|
test_waitsig();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user