1 /* Test 14. unlinking an open file. */
13 char name
[20] = {"TMP14."};
17 _PROTOTYPE(int main
, (void));
18 _PROTOTYPE(void e
, (int n
));
19 _PROTOTYPE(void quit
, (void));
28 system("rm -rf DIR_14; mkdir DIR_14");
32 name
[6] = (pid
& 037) + 33;
33 name
[7] = ((pid
* pid
) & 037) + 33;
36 for (i
= 0; i
< TRIALS
; i
++) {
37 if ( (fd0
= creat(name
, 0777)) < 0) e(1);
38 if (write(fd0
, name
, 20) != 20) e(2);
39 if (unlink(name
) != 0) e(3);
40 if (close(fd0
) != 0) e(4);
43 fd0
= creat(name
, 0777);
47 return(-1); /* impossible */
53 int err_num
= errno
; /* save errno in case printf clobbers it */
55 printf("Subtest %d, error %d errno=%d ", subtest
, n
, errno
);
56 errno
= err_num
; /* restore errno, just in case */
58 if (errct
++ > MAX_ERROR
) {
59 printf("Too many errors; test aborted\n");
61 system("rm -rf DIR*");
70 system("rm -rf DIR*");
76 printf("%d errors\n", errct
);