mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
Improve docs of more system calls
This change also found a few POSIX compliance bugs with errnos. Another bug was discovered where, on Windows, pread() and pwrite() could modify the file position in cases where ReadFile() returned an error e.g. when seeking past the end of file. We also have more tests!
This commit is contained in:
parent
af24c19db3
commit
ccbae7799e
39 changed files with 589 additions and 175 deletions
|
@ -20,6 +20,7 @@
|
|||
#include "libc/errno.h"
|
||||
#include "libc/paths.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/cocmd.internal.h"
|
||||
#include "libc/stdio/internal.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/sysv/consts/f.h"
|
||||
|
@ -50,7 +51,7 @@ FILE *popen(const char *cmdline, const char *mode) {
|
|||
} else if ((flags & O_ACCMODE) == O_WRONLY) {
|
||||
dir = 1;
|
||||
} else {
|
||||
errno = EINVAL;
|
||||
einval();
|
||||
return NULL;
|
||||
}
|
||||
if (pipe(pipefds) == -1) return NULL;
|
||||
|
@ -59,8 +60,7 @@ FILE *popen(const char *cmdline, const char *mode) {
|
|||
switch ((pid = fork())) {
|
||||
case 0:
|
||||
dup2(pipefds[!dir], !dir);
|
||||
systemexec(cmdline);
|
||||
_exit(127);
|
||||
_Exit(cocmd(3, (char *[]){"popen", "-c", cmdline, 0}));
|
||||
default:
|
||||
f->pid = pid;
|
||||
close(pipefds[!dir]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue