summaryrefslogtreecommitdiff
path: root/trans.c
diff options
context:
space:
mode:
Diffstat (limited to 'trans.c')
-rw-r--r--trans.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/trans.c b/trans.c
index 4b77f473d..ac7d9906d 100644
--- a/trans.c
+++ b/trans.c
@@ -27,6 +27,7 @@
/*---------------------------------------------------------------------------*/
#include <stdlib.h>
#include <hurd/fsys.h>
+#include <sys/wait.h>
/*---------------------------------------------------------------------------*/
#include "trans.h"
/*---------------------------------------------------------------------------*/
@@ -39,10 +40,10 @@ trans_el_t * dyntrans = NULL;
/*---------------------------------------------------------------------------*/
/*---------Functions---------------------------------------------------------*/
-/*Adds a translator control port to the list of ports. One should use
- only this function to add a new element to the list of ports. */
+/*Adds a translator to the list of translators. One should use only
+ this function to add a new element to the list. */
error_t
-trans_register (fsys_t cntl, trans_el_t ** new_trans)
+trans_register (fsys_t cntl, pid_t pid, trans_el_t ** new_trans)
{
/*The new entry in the list */
trans_el_t * el;
@@ -52,6 +53,7 @@ trans_register (fsys_t cntl, trans_el_t ** new_trans)
return ENOMEM;
el->cntl = cntl;
+ el->pid = pid;
el->prev = NULL;
el->next = dyntrans;
@@ -63,9 +65,9 @@ trans_register (fsys_t cntl, trans_el_t ** new_trans)
} /*trans_register */
/*---------------------------------------------------------------------------*/
-/*Removes a translator control port from the list of ports. One should
- use only this function to remove an element from the list of
- ports. This function does not shut down the translator. */
+/*Removes a translator from the list. One should use only this
+ function to remove an element from the list. This function does not
+ shut down the translator. */
void
trans_unregister (trans_el_t * trans)
{
@@ -78,16 +80,21 @@ trans_unregister (trans_el_t * trans)
} /*trans_unregister */
/*---------------------------------------------------------------------------*/
-/*Gracefully shuts down all the translators registered in the
- list with `flags`. */
+/*Gracefully shuts down all the translators registered in the list
+ with `flags`. If wait is nonzero, waits for each translator to
+ finish. */
error_t
-trans_shutdown_all (int flags)
+trans_shutdown_all (int flags, int wait)
{
error_t err;
/*The element being dealt with now. */
trans_el_t * el;
+ /*The exit status of the dynamic translator, in case we are waiting
+ for it to finish. */
+ int exit_status;
+
for (el = dyntrans; el; el = el->next)
{
err = fsys_goaway (el->cntl, flags);
@@ -101,6 +108,12 @@ trans_shutdown_all (int flags)
dyntrans = el;
return err;
}
+
+ if (wait)
+ {
+ /*Wait for the translator process to stop, if needed. */
+ waitpid (el->pid, &exit_status, 0);
+ }
}
dyntrans = NULL;