test68: test pipe2 functionality
Change-Id: Idb15ec83983d0b052232c9533f89d637229d19df
This commit is contained in:
33
test/t68a.c
Normal file
33
test/t68a.c
Normal file
@@ -0,0 +1,33 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int fd, fd_parent;
|
||||
char buf[1];
|
||||
|
||||
if (argc != 2) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
fd_parent = atoi(argv[1]);
|
||||
|
||||
/* If we open a new file, the fd we obtain should be fd_parent + 1 */
|
||||
fd = open("open_plusplus_fd", O_CREAT|O_RDWR, 0660);
|
||||
if (fd != fd_parent + 1) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
/* Also, writing to fd_parent should succeed */
|
||||
if (write(fd_parent, buf, sizeof(buf)) <= 0) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user