process-util: Use ret as output parameter name
There's only one output parameter for all these functions, so let's just name it ret following the coding style.
This commit is contained in:
committed by
DaanDeMeyer
parent
944ae1286b
commit
e6703a9aa4
+18
-18
@@ -1407,7 +1407,7 @@ int pidref_safe_fork_full(
|
||||
int except_fds[],
|
||||
size_t n_except_fds,
|
||||
ForkFlags flags,
|
||||
PidRef *ret_pid) {
|
||||
PidRef *ret) {
|
||||
|
||||
pid_t original_pid, pid;
|
||||
sigset_t saved_ss, ss;
|
||||
@@ -1421,7 +1421,7 @@ int pidref_safe_fork_full(
|
||||
(flags & (FORK_WAIT|FORK_DEATHSIG_SIGTERM|FORK_DEATHSIG_SIGINT|FORK_DEATHSIG_SIGKILL)) == 0);
|
||||
|
||||
/* A wrapper around fork(), that does a couple of important initializations in addition to mere
|
||||
* forking. If provided, ret_pid is initialized in both the parent and the child process, both times
|
||||
* forking. If provided, ret is initialized in both the parent and the child process, both times
|
||||
* referencing the child process. Returns == 0 in the child and > 0 in the parent. */
|
||||
|
||||
prio = flags & FORK_LOG ? LOG_ERR : LOG_DEBUG;
|
||||
@@ -1465,7 +1465,7 @@ int pidref_safe_fork_full(
|
||||
if (!r) {
|
||||
/* Not a reaper process, hence do a double fork() so we are reparented to one */
|
||||
|
||||
if (ret_pid && socketpair(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0, pidref_transport_fds) < 0)
|
||||
if (ret && socketpair(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0, pidref_transport_fds) < 0)
|
||||
return log_full_errno(prio, errno, "Failed to allocate pidref socket: %m");
|
||||
|
||||
pid = fork();
|
||||
@@ -1499,7 +1499,7 @@ int pidref_safe_fork_full(
|
||||
if (n < 0)
|
||||
return log_full_errno(prio, n, "Failed to receive child pidref: %m");
|
||||
|
||||
*ret_pid = (PidRef) { .pid = pid, .fd = pidfd };
|
||||
*ret = (PidRef) { .pid = pid, .fd = pidfd };
|
||||
}
|
||||
|
||||
return 1; /* return in the parent */
|
||||
@@ -1569,19 +1569,19 @@ int pidref_safe_fork_full(
|
||||
return -EPROTO;
|
||||
|
||||
/* If we are in the parent and successfully waited, then the process doesn't exist anymore. */
|
||||
if (ret_pid)
|
||||
*ret_pid = PIDREF_NULL;
|
||||
if (ret)
|
||||
*ret = PIDREF_NULL;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ret_pid) {
|
||||
if (ret) {
|
||||
if (FLAGS_SET(flags, _FORK_PID_ONLY))
|
||||
*ret_pid = PIDREF_MAKE_FROM_PID(pid);
|
||||
*ret = PIDREF_MAKE_FROM_PID(pid);
|
||||
else {
|
||||
r = pidref_set_pid(ret_pid, pid);
|
||||
r = pidref_set_pid(ret, pid);
|
||||
if (r < 0) /* Let's not fail for this, no matter what, the process exists after all, and that's key */
|
||||
*ret_pid = PIDREF_MAKE_FROM_PID(pid);
|
||||
*ret = PIDREF_MAKE_FROM_PID(pid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1763,11 +1763,11 @@ int pidref_safe_fork_full(
|
||||
if (FLAGS_SET(flags, FORK_FREEZE))
|
||||
freeze();
|
||||
|
||||
if (ret_pid) {
|
||||
if (ret) {
|
||||
if (FLAGS_SET(flags, _FORK_PID_ONLY))
|
||||
*ret_pid = PIDREF_MAKE_FROM_PID(getpid_cached());
|
||||
*ret = PIDREF_MAKE_FROM_PID(getpid_cached());
|
||||
else {
|
||||
r = pidref_set_self(ret_pid);
|
||||
r = pidref_set_self(ret);
|
||||
if (r < 0) {
|
||||
log_full_errno(prio, r, "Failed to acquire PID reference on ourselves: %m");
|
||||
_exit(EXIT_FAILURE);
|
||||
@@ -1784,20 +1784,20 @@ int safe_fork_full(
|
||||
int except_fds[],
|
||||
size_t n_except_fds,
|
||||
ForkFlags flags,
|
||||
pid_t *ret_pid) {
|
||||
pid_t *ret) {
|
||||
|
||||
_cleanup_(pidref_done) PidRef pidref = PIDREF_NULL;
|
||||
int r;
|
||||
|
||||
/* Getting the detached child process pid without pidfd is racy, so don't allow it if not returning
|
||||
* a pidref to the caller. */
|
||||
assert(!FLAGS_SET(flags, FORK_DETACH) || !ret_pid);
|
||||
assert(!FLAGS_SET(flags, FORK_DETACH) || !ret);
|
||||
|
||||
r = pidref_safe_fork_full(name, stdio_fds, except_fds, n_except_fds, flags|_FORK_PID_ONLY, ret_pid ? &pidref : NULL);
|
||||
if (r < 0 || !ret_pid)
|
||||
r = pidref_safe_fork_full(name, stdio_fds, except_fds, n_except_fds, flags|_FORK_PID_ONLY, ret ? &pidref : NULL);
|
||||
if (r < 0 || !ret)
|
||||
return r;
|
||||
|
||||
*ret_pid = pidref.pid;
|
||||
*ret = pidref.pid;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -186,10 +186,10 @@ int pidref_safe_fork_full(
|
||||
int except_fds[],
|
||||
size_t n_except_fds,
|
||||
ForkFlags flags,
|
||||
PidRef *ret_pid);
|
||||
PidRef *ret);
|
||||
|
||||
static inline int pidref_safe_fork(const char *name, ForkFlags flags, PidRef *ret_pid) {
|
||||
return pidref_safe_fork_full(name, NULL, NULL, 0, flags, ret_pid);
|
||||
static inline int pidref_safe_fork(const char *name, ForkFlags flags, PidRef *ret) {
|
||||
return pidref_safe_fork_full(name, NULL, NULL, 0, flags, ret);
|
||||
}
|
||||
|
||||
int safe_fork_full(
|
||||
@@ -198,10 +198,10 @@ int safe_fork_full(
|
||||
int except_fds[],
|
||||
size_t n_except_fds,
|
||||
ForkFlags flags,
|
||||
pid_t *ret_pid);
|
||||
pid_t *ret);
|
||||
|
||||
static inline int safe_fork(const char *name, ForkFlags flags, pid_t *ret_pid) {
|
||||
return safe_fork_full(name, NULL, NULL, 0, flags, ret_pid);
|
||||
static inline int safe_fork(const char *name, ForkFlags flags, pid_t *ret) {
|
||||
return safe_fork_full(name, NULL, NULL, 0, flags, ret);
|
||||
}
|
||||
|
||||
int namespace_fork_full(
|
||||
|
||||
Reference in New Issue
Block a user