mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-19 00:50:30 +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
|
@ -19,6 +19,7 @@
|
|||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/state.internal.h"
|
||||
#include "libc/calls/syscall-sysv.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/runtime/internal.h"
|
||||
|
||||
/**
|
||||
|
@ -32,16 +33,19 @@
|
|||
* programs that mix fork() with threads. In that case, apps should
|
||||
* consider using `sys_getpid().ax` instead to force a system call.
|
||||
*
|
||||
* On Linux, and only Linux, the process id is guaranteed to be the same
|
||||
* as gettid() for the main thread.
|
||||
* On Linux, and only Linux, getpid() is guaranteed to equal gettid()
|
||||
* for the main thread.
|
||||
*
|
||||
* @return process id (always successful)
|
||||
* @asyncsignalsafe
|
||||
* @threadsafe
|
||||
* @vforksafe
|
||||
*/
|
||||
int getpid(void) {
|
||||
int rc;
|
||||
if (!__vforked) {
|
||||
if (IsMetal()) {
|
||||
rc = 1;
|
||||
} else if (!__vforked) {
|
||||
rc = __pid;
|
||||
} else {
|
||||
rc = sys_getpid().ax;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue