提交 1af8c255 编写于 作者: R Rich Felker

avoid cancellation in pclose

at the point pclose might receive and act on cancellation, it has
already invalidated the FILE passed to it. thus, per musl's QOI
guarantees about cancellation and resource allocation/deallocation,
it's not a candidate for cancellation.

if it were required to be a cancellation point by posix, we would have
to switch the order of deallocation, but somehow still close the pipe
in order to trigger the child process to exit. i looked into doing
this, but the logic gets ugly, and i'm not sure the semantics are
conformant, so i'd rather just leave it alone unless there's a need to
change it.
上级 9799560f
#include "stdio_impl.h"
#include "syscall.h"
int pclose(FILE *f)
{
int status;
int status, r;
pid_t pid = f->pipe_pid;
fclose(f);
while (waitpid(pid, &status, 0) == -1)
if (errno != EINTR) return -1;
while ((r=__syscall(SYS_wait4, pid, &status, 0, 0)) == -EINTR);
if (r<0) return __syscall_ret(r);
return status;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册