Rename struct exit_status in os_calls

This conflicts with struct exit_status in <utmp.h>
This commit is contained in:
matt335672 2023-06-29 15:20:39 +01:00
parent 49f60fc64f
commit bc9b35c38c
8 changed files with 42 additions and 38 deletions

View File

@ -3302,10 +3302,10 @@ g_set_allusercontext(int uid)
/*****************************************************************************/
/* does not work in win32
returns pid of process that exits or zero if signal occurred
an exit_status struct can optionally be passed in to get the
a proc_exit_status struct can optionally be passed in to get the
exit status of the child */
int
g_waitchild(struct exit_status *e)
g_waitchild(struct proc_exit_status *e)
{
#if defined(_WIN32)
return 0;
@ -3313,14 +3313,14 @@ g_waitchild(struct exit_status *e)
int wstat;
int rv;
struct exit_status dummy;
struct proc_exit_status dummy;
if (e == NULL)
{
e = &dummy; // Set this, then throw it away
}
e->reason = E_XR_UNEXPECTED;
e->reason = E_PXR_UNEXPECTED;
e->val = 0;
rv = waitpid(-1, &wstat, WNOHANG);
@ -3335,12 +3335,12 @@ g_waitchild(struct exit_status *e)
}
else if (WIFEXITED(wstat))
{
e->reason = E_XR_STATUS_CODE;
e->reason = E_PXR_STATUS_CODE;
e->val = WEXITSTATUS(wstat);
}
else if (WIFSIGNALED(wstat))
{
e->reason = E_XR_SIGNAL;
e->reason = E_PXR_SIGNAL;
e->val = WTERMSIG(wstat);
}
@ -3381,10 +3381,14 @@ g_waitpid(int pid)
Note that signal handlers are established with BSD-style semantics,
so this call is NOT interrupted by a signal */
struct exit_status
struct proc_exit_status
g_waitpid_status(int pid)
{
struct exit_status exit_status = {.reason = E_XR_UNEXPECTED, .val = 0};
struct proc_exit_status exit_status =
{
.reason = E_PXR_UNEXPECTED,
.val = 0
};
#if !defined(_WIN32)
if (pid > 0)
@ -3399,12 +3403,12 @@ g_waitpid_status(int pid)
{
if (WIFEXITED(status))
{
exit_status.reason = E_XR_STATUS_CODE;
exit_status.reason = E_PXR_STATUS_CODE;
exit_status.val = WEXITSTATUS(status);
}
if (WIFSIGNALED(status))
{
exit_status.reason = E_XR_SIGNAL;
exit_status.reason = E_PXR_SIGNAL;
exit_status.val = WTERMSIG(status);
}
}

View File

@ -23,16 +23,16 @@
#include "arch.h"
enum exit_reason
enum proc_exit_reason
{
E_XR_STATUS_CODE = 0, ///< 'val' contains exit status
E_XR_SIGNAL, ///< 'val' contains a signal number
E_XR_UNEXPECTED
E_PXR_STATUS_CODE = 0, ///< 'val' contains exit status
E_PXR_SIGNAL, ///< 'val' contains a signal number
E_PXR_UNEXPECTED
};
struct exit_status
struct proc_exit_status
{
enum exit_reason reason;
enum proc_exit_reason reason;
int val;
};
@ -352,9 +352,9 @@ int g_setlogin(const char *name);
*/
int g_set_allusercontext(int uid);
#endif
int g_waitchild(struct exit_status *e);
int g_waitchild(struct proc_exit_status *e);
int g_waitpid(int pid);
struct exit_status g_waitpid_status(int pid);
struct proc_exit_status g_waitpid_status(int pid);
/*
* Sets the process group ID of the indicated process to the specified value.
* (POSIX.1)

View File

@ -241,7 +241,7 @@ sesexec_terminate_main_loop(int status)
static void
process_sigchld_event(void)
{
struct exit_status e;
struct proc_exit_status e;
int pid;
// Check for any finished children

View File

@ -811,11 +811,11 @@ cleanup_sockets(int uid, int display)
/******************************************************************************/
static void
exit_status_to_str(const struct exit_status *e, char buff[], int bufflen)
exit_status_to_str(const struct proc_exit_status *e, char buff[], int bufflen)
{
switch (e->reason)
{
case E_XR_STATUS_CODE:
case E_PXR_STATUS_CODE:
if (e->val == 0)
{
g_snprintf(buff, bufflen, "exit code zero");
@ -826,7 +826,7 @@ exit_status_to_str(const struct exit_status *e, char buff[], int bufflen)
}
break;
case E_XR_SIGNAL:
case E_PXR_SIGNAL:
{
char sigstr[MAXSTRSIGLEN];
g_snprintf(buff, bufflen, "signal %s",
@ -844,7 +844,7 @@ exit_status_to_str(const struct exit_status *e, char buff[], int bufflen)
void
session_process_child_exit(struct session_data *sd,
int pid,
const struct exit_status *e)
const struct proc_exit_status *e)
{
if (pid == sd->x_server)
{
@ -864,7 +864,7 @@ session_process_child_exit(struct session_data *sd,
{
int wm_wait_time = g_time1() - sd->start_time;
if (e->reason == E_XR_STATUS_CODE && e->val == 0)
if (e->reason == E_PXR_STATUS_CODE && e->val == 0)
{
LOG(LOG_LEVEL_INFO,
"Window manager (pid %d, display %d) "

View File

@ -35,7 +35,7 @@
#include "xrdp_constants.h"
struct login_info;
struct exit_status;
struct proc_exit_status;
/**
* Information used to start a session
@ -89,7 +89,7 @@ session_start(struct login_info *login_info,
void
session_process_child_exit(struct session_data *sd,
int pid,
const struct exit_status *e);
const struct proc_exit_status *e);
/**
* Returns a count of active processes in the session

View File

@ -142,7 +142,7 @@ wait_for_xserver(uid_t uid,
}
else
{
struct exit_status e;
struct proc_exit_status e;
fd[0] = -1; // File descriptor closed by fclose()
log_waitforx_messages(dp);
@ -150,11 +150,11 @@ wait_for_xserver(uid_t uid,
e = g_waitpid_status(pid);
switch (e.reason)
{
case E_XR_STATUS_CODE:
case E_PXR_STATUS_CODE:
rv = (enum xwait_status)e.val;
break;
case E_XR_SIGNAL:
case E_PXR_SIGNAL:
{
char sigstr[MAXSTRSIGLEN];
LOG(LOG_LEVEL_ERROR,

View File

@ -79,7 +79,7 @@ END_TEST
/******************************************************************************/
START_TEST(test_g_signal_child_stop_1)
{
struct exit_status e;
struct proc_exit_status e;
g_reset_wait_obj(g_wobj1);
ck_assert_int_eq(g_is_wait_obj_set(g_wobj1), 0);
@ -98,7 +98,7 @@ START_TEST(test_g_signal_child_stop_1)
e = g_waitpid_status(pid);
ck_assert_int_eq(e.reason, E_XR_STATUS_CODE);
ck_assert_int_eq(e.reason, E_PXR_STATUS_CODE);
ck_assert_int_eq(e.val, 45);
// Try another one to make sure the signal handler is still in place.
@ -116,7 +116,7 @@ START_TEST(test_g_signal_child_stop_1)
e = g_waitpid_status(pid);
ck_assert_int_eq(e.reason, E_XR_SIGNAL);
ck_assert_int_eq(e.reason, E_PXR_SIGNAL);
ck_assert_int_eq(e.val, SIGSEGV);
// Clean up
@ -133,7 +133,7 @@ START_TEST(test_g_signal_child_stop_2)
int pids[CHILD_COUNT];
unsigned int i;
struct exit_status e;
struct proc_exit_status e;
g_reset_wait_obj(g_wobj1);
ck_assert_int_eq(g_is_wait_obj_set(g_wobj1), 0);
@ -157,7 +157,7 @@ START_TEST(test_g_signal_child_stop_2)
for (i = 0 ; i < CHILD_COUNT; ++i)
{
e = g_waitpid_status(pids[i]);
ck_assert_int_eq(e.reason, E_XR_STATUS_CODE);
ck_assert_int_eq(e.reason, E_PXR_STATUS_CODE);
ck_assert_int_eq(e.val, (i + 1));
}
@ -246,12 +246,12 @@ START_TEST(test_waitpid_not_interrupted_by_sig)
g_reset_wait_obj(g_wobj1);
g_set_alarm(set_wobj1, 1);
struct exit_status e = g_waitpid_status(child_pid);
struct proc_exit_status e = g_waitpid_status(child_pid);
// We should have had the alarm...
ck_assert_int_ne(g_is_wait_obj_set(g_wobj1), 0);
// ..and got the status of the child
ck_assert_int_eq(e.reason, E_XR_STATUS_CODE);
ck_assert_int_eq(e.reason, E_PXR_STATUS_CODE);
ck_assert_int_eq(e.val, 42);
// Clean up

View File

@ -856,12 +856,12 @@ xrdp_listen_conn_in(struct trans *self, struct trans *new_self)
static void
process_pending_sigchld_events(void)
{
struct exit_status e;
struct proc_exit_status e;
int pid;
while ((pid = g_waitchild(&e)) > 0)
{
if (e.reason == E_XR_SIGNAL)
if (e.reason == E_PXR_SIGNAL)
{
char sigstr[MAXSTRSIGLEN];
LOG(LOG_LEVEL_ERROR,