diff options
Diffstat (limited to 'start-translator-long.c')
| -rw-r--r-- | start-translator-long.c | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/start-translator-long.c b/start-translator-long.c index 174fe97..69816c8 100644 --- a/start-translator-long.c +++ b/start-translator-long.c @@ -202,7 +202,7 @@ fshelp_start_translator_long (fshelp_open_fn_t underlying_open_fn, file_t executable; mach_port_t bootstrap = MACH_PORT_NULL; mach_port_t task = MACH_PORT_NULL; - mach_port_t prev_notify, proc, saveport, childproc; + mach_port_t prev_notify, proc, childproc; int ports_moved = 0; /* Find the translator itself. Since argz has zero-separated elements, we @@ -211,11 +211,17 @@ fshelp_start_translator_long (fshelp_open_fn_t underlying_open_fn, if (executable == MACH_PORT_NULL) return errno; - /* Create a bootstrap port for the translator. */ - err = - mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &bootstrap); - if (err) - goto lose; + if (ports[INIT_PORT_BOOTSTRAP] == MACH_PORT_NULL) + { + /* Create a bootstrap port for the translator. */ + err = + mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, + &bootstrap); + if (err) + goto lose; + + ports[INIT_PORT_BOOTSTRAP] = bootstrap; + } /* Create the task for the translator. */ err = task_create (mach_task_self (), @@ -269,9 +275,6 @@ fshelp_start_translator_long (fshelp_open_fn_t underlying_open_fn, abort (); } - saveport = ports[INIT_PORT_BOOTSTRAP]; - ports[INIT_PORT_BOOTSTRAP] = bootstrap; - /* Try and exec the translator in TASK... */ err = file_exec (executable, task, EXEC_DEFAULTS, argz, argz_len, 0, 0, @@ -280,10 +283,6 @@ fshelp_start_translator_long (fshelp_open_fn_t underlying_open_fn, ints, ints_len, 0, 0, 0, 0); ports_moved = 1; - if (ports_type == MACH_MSG_TYPE_COPY_SEND) - mach_port_deallocate (mach_task_self (), bootstrap); - ports[INIT_PORT_BOOTSTRAP] = saveport; - if (err) { task_terminate (task); @@ -293,8 +292,11 @@ fshelp_start_translator_long (fshelp_open_fn_t underlying_open_fn, /* Ask to be told if TASK dies. */ err = mach_port_request_notification(mach_task_self(), - bootstrap, MACH_NOTIFY_NO_SENDERS, 0, - bootstrap, MACH_MSG_TYPE_MAKE_SEND_ONCE, + ports[INIT_PORT_BOOTSTRAP], + MACH_NOTIFY_NO_SENDERS, + 0, + ports[INIT_PORT_BOOTSTRAP], + MACH_MSG_TYPE_MAKE_SEND_ONCE, &prev_notify); if (err) return err; @@ -317,7 +319,10 @@ fshelp_start_translator_long (fshelp_open_fn_t underlying_open_fn, mach_port_deallocate (mach_task_self (), ports[i]); } if (bootstrap != MACH_PORT_NULL) - mach_port_destroy(mach_task_self(), bootstrap); + { + mach_port_destroy(mach_task_self(), bootstrap); + ports[INIT_PORT_BOOTSTRAP] = MACH_PORT_NULL; + } if (executable != MACH_PORT_NULL) mach_port_deallocate(mach_task_self(), executable); if (task != MACH_PORT_NULL) |
