2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-28 12:57:57 +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:
Andrey Vagin 2012-11-02 17:43:30 +04:00 committed by Pavel Emelyanov
parent e6bd325845
commit a943071e44

View File

@ -5,7 +5,6 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <signal.h>
#include <sys/wait.h>
#include <termios.h>
#include <sys/ioctl.h>
@ -13,11 +12,6 @@
const char *test_doc = "Check a non-controling terminal";
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 fdm, fds;
@ -26,8 +20,6 @@ int main(int argc, char ** argv)
test_init(argc, argv);
signal(SIGHUP, sighup_handler);
setsid();
fdm = open("/dev/ptmx", O_RDWR);
@ -41,17 +33,12 @@ int main(int argc, char ** argv)
slavename = ptsname(fdm);
/* set up a controlling terminal */
fds = open(slavename, O_RDWR);
fds = open(slavename, O_RDWR | O_NOCTTY);
if (fds == -1) {
err("Can't open a slave pseudoterminal %s", slavename);
return 1;
}
if (ioctl(fds, TIOCNOTTY)) {
err("Unable to detach a terminal");
return 1;
}
test_daemon();
test_waitsig();