Created
February 4, 2017 17:12
-
-
Save elieux/7b25ae87b981ddac537b09841e6ec079 to your computer and use it in GitHub Desktop.
Cygwin unlinked /proc/self/fd/* is ENOENT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sys/stat.h> | |
#include <fcntl.h> | |
#include <unistd.h> | |
#include <stdio.h> | |
#include <alloca.h> | |
int main() { | |
char path[] = "tmp"; | |
int r; | |
int fd = open(path, O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0600); | |
printf("open(\"%s\", ...) = %d\n", path, fd); | |
r = unlink(path); | |
printf("unlink(\"%s\") = %d\n", path, r); | |
char *buf = alloca(20); | |
sprintf(buf, "/proc/self/fd/%d", fd); | |
r = open(buf, O_RDONLY); | |
printf("open(\"%s\", ...) = %d\n", buf, r); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Linux$ gcc -Wall test.c -o x && ./test | |
open("tmp", ...) = 3 | |
unlink("tmp") = 0 | |
open("/proc/self/fd/3", ...) = 4 | |
Cygwin$ gcc -Wall test.c -o x && ./test | |
open("tmp", ...) = 3 | |
unlink("tmp") = 0 | |
open("/proc/self/fd/3", ...) = -1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment