blob: 8d44b38c345e56976ffc7f85a9b4367ac4d85ea4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
/* ==== test_fork.c ============================================================
* Copyright (c) 1994 by Chris Provenzano, proven@athena.mit.edu
*
* Description : Test fork() and dup2() calls.
*
* 1.00 94/04/29 proven
* -Started coding this file.
*/
#include <pthread.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <unistd.h>
#include "test.h"
int
main()
{
int flags;
pid_t pid;
extern int _thread_sys_fcntl __P((int, int, ...));
if (((flags = _thread_sys_fcntl(1, F_GETFL, NULL)) >= OK) &&
(flags & (O_NONBLOCK | O_NDELAY))) {
_thread_sys_fcntl(1, F_SETFL, flags & ~(O_NONBLOCK | O_NDELAY));
}
printf("parent process %d\n", getpid());
switch(pid = fork()) {
case OK:
exit(OK);
case NOTOK:
printf("fork() FAILED\n");
exit(2);
default:
printf("child process %d\n", pid);
break;
}
printf("test_fork PASSED\n");
return 0;
}
|