mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-28 00:02:28 +00:00
Rewrite special file handling on Windows
This change gets GNU grep working. What caused it to not work, is it wouldn't write to an output file descriptor when its dev/ino equaled /dev/null's. So now we invent special dev/ino values for these files
This commit is contained in:
parent
aca2261cda
commit
2db2f40a98
53 changed files with 485 additions and 299 deletions
|
@ -96,11 +96,19 @@ static wontreturn void UnsupportedSyntax(unsigned char c) {
|
|||
}
|
||||
|
||||
static void Open(const char *path, int fd, int flags) {
|
||||
close(fd);
|
||||
if (open(path, flags, 0644) == -1) {
|
||||
int tmpfd;
|
||||
// use open+dup2 to support things like >/dev/stdout
|
||||
if ((tmpfd = open(path, flags, 0644)) == -1) {
|
||||
perror(path);
|
||||
_Exit(1);
|
||||
}
|
||||
if (tmpfd != fd) {
|
||||
if (dup2(tmpfd, fd) == -1) {
|
||||
perror("dup2");
|
||||
_Exit(1);
|
||||
}
|
||||
close(tmpfd);
|
||||
}
|
||||
}
|
||||
|
||||
static int SystemExec(void) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue