diff options
author | David Leonard <d@cvs.openbsd.org> | 1998-09-03 11:04:48 +0000 |
---|---|---|
committer | David Leonard <d@cvs.openbsd.org> | 1998-09-03 11:04:48 +0000 |
commit | 19238dc05c5b501a685537b1fcb0b54f9d8bdf5a (patch) | |
tree | eae5c85762af12da5994ab4524ee73f6d6ba678e /lib/libc_r/TEST/test_execve.c | |
parent | 542ab5713f06e4f89b3d17d7a1458a4214fa1bb9 (diff) |
libpthread tests modified for uthreads
Diffstat (limited to 'lib/libc_r/TEST/test_execve.c')
-rw-r--r-- | lib/libc_r/TEST/test_execve.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/lib/libc_r/TEST/test_execve.c b/lib/libc_r/TEST/test_execve.c new file mode 100644 index 00000000000..409b37bfc1b --- /dev/null +++ b/lib/libc_r/TEST/test_execve.c @@ -0,0 +1,55 @@ +/* ==== test_execve.c ============================================================ + * Copyright (c) 1994 by Chris Provenzano, proven@athena.mit.edu + * + * Description : Test execve() and dup2() calls. + * + * 1.00 94/04/29 proven + * -Started coding this file. + */ + +#include <pthread.h> +#include <string.h> +#include <unistd.h> +#include <fcntl.h> +#include <stdio.h> +#include <err.h> +#include "test.h" + +extern char **environ; +char *argv[] = { + "/bin/echo", + "This message should be displayed after the execve system call", + NULL +}; + +char * should_succeed = "This line should be displayed\n"; +char * should_fail = "Error: This line should NOT be displayed\n"; + +int +main() +{ + int fd; + + printf("This is the first message\n"); + if (isatty(1)) { + char *ttynm; + + ttynm = ttyname(1); + printf("tty is %s\n", ttynm); + if ((fd = open(ttynm, O_RDWR)) < OK) + err(1, "%s", ttynm); + } else + errx(1, "stdout not a tty"); + + printf("This output is necessary to set the stdout fd to NONBLOCKING\n"); + + /* do a dup2 */ + dup2(fd, 1); + write(1, should_succeed, (size_t)strlen(should_succeed)); + _thread_sys_write(1, should_fail, strlen(should_fail)); + + if (execve(argv[0], argv, environ) < OK) + err(1, "execve"); + + PANIC(); +} |