mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 05:42:29 +00:00
Add Linux ptrace() tutorial
This commit is contained in:
parent
98909b1391
commit
3b9e66ecba
14 changed files with 1290 additions and 23 deletions
|
@ -56,21 +56,18 @@ static int openpathname(const char *pathname, int flags, bool *out_noclose) {
|
|||
* @note microsoft unilaterally deprecated this function lool
|
||||
*/
|
||||
FILE *fopen(const char *pathname, const char *mode) {
|
||||
FILE *f;
|
||||
FILE *f = 0;
|
||||
bool noclose;
|
||||
int fd, flags;
|
||||
STRACE("fopen(%s)", pathname);
|
||||
flags = fopenflags(mode);
|
||||
pathname = fixpathname(pathname, flags);
|
||||
if ((fd = openpathname(pathname, flags, &noclose)) != -1) {
|
||||
if ((f = fdopen(fd, mode)) != NULL) {
|
||||
f->noclose = noclose;
|
||||
return f;
|
||||
} else {
|
||||
if (!noclose) close(fd);
|
||||
return NULL;
|
||||
} else if (!noclose) {
|
||||
close(fd);
|
||||
}
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
STRACE("fopen(%#s, %#s) → %p% m", pathname, mode, f);
|
||||
return f;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue