Skip to content

Instantly share code, notes, and snippets.

@elieux
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elieux/6463521192baed613099 to your computer and use it in GitHub Desktop.
Save elieux/6463521192baed613099 to your computer and use it in GitHub Desktop.
cygwin+subst issue
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
int main() {
const char const* fn = "foo";
int handle1, handle2, res;
handle1 = open(fn, O_RDONLY | O_CREAT);
if (handle1 == -1) {
perror("open #1");
}
res = unlink(fn);
if (res == -1) {
perror("unlink");
}
handle2 = open(fn, O_WRONLY | O_CREAT);
if (handle2 == -1) {
perror("open #2");
}
close(handle2);
close(handle1);
return 0;
}
#!/usr/bin/bash
touch foo
{ rm foo; touch foo; } <foo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment