1.1 --- a/libfsclient/lib/src/process.cc Mon Apr 03 22:10:42 2023 +0200
1.2 +++ b/libfsclient/lib/src/process.cc Tue Apr 04 23:11:00 2023 +0200
1.3 @@ -34,6 +34,17 @@
1.4
1.5
1.6
1.7 +/* Utility functions. */
1.8 +
1.9 +static bool _process_terminated(process_t *process)
1.10 +{
1.11 + return ((process->notifiable.notifications & NOTIFY_TASK_SIGNAL) &&
1.12 + (process->notifiable.values.sig == 0)) ||
1.13 + (process->notifiable.notifications & NOTIFY_TASK_ERROR);
1.14 +}
1.15 +
1.16 +
1.17 +
1.18 /* Create a new process object. */
1.19
1.20 process_t *process_new()
1.21 @@ -60,6 +71,16 @@
1.22 process_init(process);
1.23 }
1.24
1.25 +/* Return any process initiation error. */
1.26 +
1.27 +long process_error(process_t *process)
1.28 +{
1.29 + if (process->notifiable.notifications & NOTIFY_TASK_ALL)
1.30 + return process->notifiable.values.val;
1.31 + else
1.32 + return L4_EOK;
1.33 +}
1.34 +
1.35 /* Initialise the given process structure. */
1.36
1.37 void process_init(process_t *process)
1.38 @@ -69,6 +90,7 @@
1.39 /* Initialise the notifiable section of the structure. */
1.40
1.41 process->notifiable.notifications = 0;
1.42 + process->notifiable.pending_notifications = 0;
1.43 process->notifiable.base = (notifiable_base_t *) process;
1.44 process->notifiable.handler = NULL;
1.45 }
1.46 @@ -76,7 +98,7 @@
1.47 /* Start a process using the given arguments.
1.48 NOTE: This does not yet obtain input/output pipes. */
1.49
1.50 -long process_start(process_t *process, int argc, char *argv[])
1.51 +long process_start(process_t *process, int argc, const char *argv[])
1.52 {
1.53 l4_cap_idx_t server = l4re_env_get_cap(ENV_PROCESS_SERVER_NAME);
1.54
1.55 @@ -112,6 +134,7 @@
1.56 /* Initialise the notifiable section of the structure. */
1.57
1.58 process->notifiable.notifications = 0;
1.59 + process->notifiable.pending_notifications = 0;
1.60 process->notifiable.base = (notifiable_base_t *) process;
1.61
1.62 /* Close the context, although a separate mechanism could permit contexts to
1.63 @@ -204,12 +227,8 @@
1.64
1.65 /* Unsubscribe if a termination notification has been received. */
1.66
1.67 - if (!err && (process->notifiable.notifications & NOTIFY_TASK_SIGNAL) &&
1.68 - (process->notifiable.values.sig == 0))
1.69 - {
1.70 + if (!err && _process_terminated(process))
1.71 process_notify_unsubscribe(process, notifier);
1.72 - process_close(process);
1.73 - }
1.74
1.75 return err;
1.76 }
1.77 @@ -225,12 +244,8 @@
1.78
1.79 /* Unsubscribe if a termination notification has been received. */
1.80
1.81 - if (!err && ((*process)->notifiable.notifications & NOTIFY_TASK_SIGNAL) &&
1.82 - ((*process)->notifiable.values.sig == 0))
1.83 - {
1.84 + if (!err && _process_terminated(*process))
1.85 process_notify_unsubscribe(*process, notifier);
1.86 - process_close(*process);
1.87 - }
1.88
1.89 return err;
1.90 }