1.1 --- a/libfsclient/lib/src/process.cc Tue Feb 28 22:40:02 2023 +0100
1.2 +++ b/libfsclient/lib/src/process.cc Fri Mar 03 18:15:38 2023 +0100
1.3 @@ -46,16 +46,24 @@
1.4 return process;
1.5 }
1.6
1.7 +/* Discard the given process. */
1.8 +
1.9 +void process_close(process_t *process)
1.10 +{
1.11 + if (process == NULL)
1.12 + return;
1.13 +
1.14 + if (l4_is_valid_cap(process->ref))
1.15 + ipc_cap_free_um(process->ref);
1.16 +
1.17 + process_init(process);
1.18 +}
1.19 +
1.20 /* Initialise the given process structure. */
1.21
1.22 void process_init(process_t *process)
1.23 {
1.24 process->ref = L4_INVALID_CAP;
1.25 -
1.26 - /* Initialise the notifiable section of the structure. */
1.27 -
1.28 - process->notifiable.notifications = 0;
1.29 - process->notifiable.base = (notifiable_base_t *) process;
1.30 }
1.31
1.32 /* Start a process using the given arguments.
1.33 @@ -94,6 +102,11 @@
1.34
1.35 err = creator.start(argc, &process->ref);
1.36
1.37 + /* Initialise the notifiable section of the structure. */
1.38 +
1.39 + process->notifiable.notifications = 0;
1.40 + process->notifiable.base = (notifiable_base_t *) process;
1.41 +
1.42 /* Close the context, although a separate mechanism could permit contexts to
1.43 open several processes. */
1.44
1.45 @@ -187,7 +200,10 @@
1.46
1.47 if (!err && (process->notifiable.notifications & NOTIFY_TASK_SIGNAL) &&
1.48 (process->notifiable.values.sig == 0))
1.49 + {
1.50 process_notify_unsubscribe(process, notifier);
1.51 + process_close(process);
1.52 + }
1.53
1.54 return err;
1.55 }
1.56 @@ -206,7 +222,10 @@
1.57
1.58 if (!err && ((*process)->notifiable.notifications & NOTIFY_TASK_SIGNAL) &&
1.59 ((*process)->notifiable.values.sig == 0))
1.60 + {
1.61 process_notify_unsubscribe(*process, notifier);
1.62 + process_close(*process);
1.63 + }
1.64
1.65 return err;
1.66 }