diff --git a/test/zdtm/live/static/Makefile b/test/zdtm/live/static/Makefile index af0d09aea..e51e2175f 100644 --- a/test/zdtm/live/static/Makefile +++ b/test/zdtm/live/static/Makefile @@ -55,6 +55,7 @@ TST_NOFILE = \ pty01 \ pty02 \ pty03 \ + pty04 \ tty00 \ mountpoints \ netns \ diff --git a/test/zdtm/live/static/pty04.c b/test/zdtm/live/static/pty04.c new file mode 100644 index 000000000..79048f3b4 --- /dev/null +++ b/test/zdtm/live/static/pty04.c @@ -0,0 +1,64 @@ +#define _XOPEN_SOURCE +#include +#include "zdtmtst.h" +#include +#include +#include +#include +#include +#include +#include +#include + +const char *test_doc = "Check two pts with a fake ptmx"; +const char *test_author = "Cyrill Gorcunov "; + +int main(int argc, char *argv[]) +{ + int master, slave1, slave2; + char *slavename; + + test_init(argc, argv); + + master = open("/dev/ptmx", O_RDWR); + if (master == -1) { + err("open(%s) failed", "/dev/ptmx"); + return 1; + } + + grantpt(master); + unlockpt(master); + + slavename = ptsname(master); + + slave1 = open(slavename, O_RDWR); + if (slave1 == -1) { + err("open(%s) failed", slavename); + return 1; + } + + slave2 = open(slavename, O_RDWR); + if (slave2 == -1) { + err("open(%s) failed", slavename); + return 1; + } + + if (ioctl(slave1, TIOCSCTTY, 1)) { + err("Can't set a controll terminal"); + return 1; + } + + test_msg("Closing master\n"); + signal(SIGHUP, SIG_IGN); + close(master); + + test_daemon(); + test_waitsig(); + + close(slave1); + close(slave2); + + pass(); + + return 0; +}