lib/libsys, lib/libc: export pdwait
Make pdwait(2) cancellable, same as all other wait*(2) syscalls wrappers. Reviewed by: asomers, markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D54592
This commit is contained in:
@@ -252,6 +252,7 @@ enum {
|
||||
INTERPOS__reserved0, /* was distribute_static_tls */
|
||||
INTERPOS_pdfork,
|
||||
INTERPOS_uexterr_gettext,
|
||||
INTERPOS_pdwait,
|
||||
INTERPOS_MAX
|
||||
};
|
||||
|
||||
|
||||
@@ -71,3 +71,7 @@ FBSD_1.6 {
|
||||
FBSD_1.7 {
|
||||
_Fork;
|
||||
};
|
||||
|
||||
FBSD_1.9 {
|
||||
pdwait;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2026 The FreeBSD Foundation.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* This software was developed by Konstantin Belousov <kib@FreeBSD.org>
|
||||
* under sponsorship from the FreeBSD Foundation.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/procdesc.h>
|
||||
#include "libc_private.h"
|
||||
|
||||
#pragma weak pdwait
|
||||
int
|
||||
pdwait(int fd, int *status, int options, struct __wrusage *ru,
|
||||
struct __siginfo *infop)
|
||||
{
|
||||
return (INTERPOS_SYS(pdwait, fd, status, options, ru, infop));
|
||||
}
|
||||
@@ -73,6 +73,7 @@ INTERPOSED = \
|
||||
open \
|
||||
openat \
|
||||
pdfork \
|
||||
pdwait \
|
||||
poll \
|
||||
ppoll \
|
||||
pselect \
|
||||
|
||||
@@ -72,6 +72,7 @@ static interpos_func_t __libsys_interposing[INTERPOS_MAX] = {
|
||||
SLOT(fdatasync, __sys_fdatasync),
|
||||
SLOT(clock_nanosleep, __sys_clock_nanosleep),
|
||||
SLOT(pdfork, __sys_pdfork),
|
||||
SLOT(pdwait, __sys_pdwait),
|
||||
};
|
||||
#undef SLOT
|
||||
|
||||
|
||||
@@ -584,6 +584,20 @@ __thr_wait6(idtype_t idtype, id_t id, int *status, int options,
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static pid_t
|
||||
__thr_pdwait(int fd, int *status, int options, struct __wrusage *ru,
|
||||
siginfo_t *infop)
|
||||
{
|
||||
struct pthread *curthread;
|
||||
pid_t ret;
|
||||
|
||||
curthread = _get_curthread();
|
||||
_thr_cancel_enter(curthread);
|
||||
ret = __sys_pdwait(fd, status, options, ru, infop);
|
||||
_thr_cancel_leave(curthread, ret == -1);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*
|
||||
* Cancellation behavior:
|
||||
* Thread may be canceled at start, but if the thread wrote some data,
|
||||
@@ -685,6 +699,7 @@ __thr_interpose_libc(void)
|
||||
SLOT(clock_nanosleep);
|
||||
SLOT(pdfork);
|
||||
SLOT(uexterr_gettext);
|
||||
SLOT(pdwait);
|
||||
#undef SLOT
|
||||
*(__libc_interposing_slot(
|
||||
INTERPOS__pthread_mutex_init_calloc_cb)) =
|
||||
|
||||
@@ -122,10 +122,14 @@ struct rusage;
|
||||
* Process descriptor system calls.
|
||||
*/
|
||||
__BEGIN_DECLS
|
||||
struct __wrusage;
|
||||
struct __siginfo;
|
||||
|
||||
pid_t pdfork(int *, int);
|
||||
pid_t pdrfork(int *, int, int);
|
||||
int pdkill(int, int);
|
||||
int pdgetpid(int, pid_t *);
|
||||
int pdwait(int, int *, int, struct __wrusage *, struct __siginfo *);
|
||||
__END_DECLS
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
Reference in New Issue
Block a user