added demo of signal/uid handling feature
[tridge/junkcode.git] / opentest.c
1 #include <fcntl.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <unistd.h>
5 #include <errno.h>
6
7
8 char *fname = "test.tmp";
9
10 void main()
11 {
12   int fd;
13
14   /* create a readonly file */
15   unlink(fname);
16   if ((fd=open(fname,O_RDWR|O_CREAT,0444)) == -1) {
17     printf("first open failed : %s\n",strerror(errno));
18     exit(1);
19   }
20   close(fd);
21
22   /* try and open it for reading. This should work. Under linux 2.0 it doesn't */
23   if ((fd=open(fname,O_RDONLY|O_CREAT,0666)) == -1) {
24     printf("2nd open failed : %s\n",strerror(errno));
25     exit(1);
26   }
27   close(fd);
28
29   /* it worked - clean up */
30   unlink(fname);
31
32   printf("all OK\n");
33 }