@@ -86,7 +86,7 @@ static void start_cb (struct bulk_exec *exec, void *arg)
8686 /* This is going to be really slow. However, it should at least
8787 * work for now. We wait for all imp's to start, then send input
8888 */
89- if (job -> multiuser ) {
89+ if (job -> multiuser && ! config_use_imp_helper () ) {
9090 char * input = NULL ;
9191 json_t * o = json_pack ("{s:s}" , "J" , job -> J );
9292 if (!o || !(input = json_dumps (o , JSON_COMPACT ))) {
@@ -117,13 +117,13 @@ static void complete_cb (struct bulk_exec *exec, void *arg)
117117static int exec_barrier_enter (struct bulk_exec * exec )
118118{
119119 struct exec_ctx * ctx = bulk_exec_aux_get (exec , "ctx" );
120+ const char * stream = config_use_imp_helper () ?
121+ "stdin" :
122+ "FLUX_EXEC_PROTOCOL_FD" ;
120123 if (!ctx )
121124 return -1 ;
122125 if (++ ctx -> barrier_enter_count == bulk_exec_total (exec )) {
123- if (bulk_exec_write (exec ,
124- "FLUX_EXEC_PROTOCOL_FD" ,
125- "exit=0\n" ,
126- 7 ) < 0 )
126+ if (bulk_exec_write (exec , stream , "exit=0\n" , 7 ) < 0 )
127127 return -1 ;
128128 ctx -> barrier_enter_count = 0 ;
129129 ctx -> barrier_completion_count ++ ;
@@ -135,10 +135,7 @@ static int exec_barrier_enter (struct bulk_exec *exec)
135135 * case where a shell exits while a barrier is already in progress
136136 * is handled in exit_cb().
137137 */
138- if (bulk_exec_write (exec ,
139- "FLUX_EXEC_PROTOCOL_FD" ,
140- "exit=1\n" ,
141- 7 ) < 0 )
138+ if (bulk_exec_write (exec , stream , "exit=1\n" , 7 ) < 0 )
142139 return -1 ;
143140 }
144141 return 0 ;
@@ -153,7 +150,8 @@ static void output_cb (struct bulk_exec *exec, flux_subprocess_t *p,
153150 struct jobinfo * job = arg ;
154151 const char * cmd = flux_cmd_arg (flux_subprocess_get_cmd (p ), 0 );
155152
156- if (streq (stream , "FLUX_EXEC_PROTOCOL_FD" )) {
153+ if (streq (stream , "FLUX_EXEC_PROTOCOL_FD" )
154+ || (config_use_imp_helper () && streq (stream , "stdout" ))) {
157155 if (streq (data , "enter\n" )
158156 && exec_barrier_enter (exec ) < 0 ) {
159157 jobinfo_fatal_error (job ,
@@ -293,10 +291,10 @@ static void exit_cb (struct bulk_exec *exec,
293291 */
294292 if (ctx -> barrier_completion_count == 0
295293 || ctx -> barrier_enter_count > 0 ) {
296- if ( bulk_exec_write ( exec ,
297- "FLUX_EXEC_PROTOCOL_FD" ,
298- "exit=1\n" ,
299- 7 ) < 0 )
294+ const char * stream = config_use_imp_helper () ?
295+ "stdin" :
296+ "FLUX_EXEC_PROTOCOL_FD" ;
297+ if ( bulk_exec_write ( exec , stream , "exit=1\n" , 7 ) < 0 )
300298 jobinfo_fatal_error (job , 0 ,
301299 "failed to terminate barrier: %s" ,
302300 strerror (errno ));
@@ -351,6 +349,15 @@ static int exec_init (struct jobinfo *job)
351349 goto err ;
352350 }
353351 if (job -> multiuser ) {
352+ if (config_use_imp_helper ()
353+ && flux_cmd_setenvf (cmd ,
354+ 1 ,
355+ "FLUX_IMP_EXEC_HELPER" ,
356+ "flux imp-exec-helper %ju" ,
357+ (uintmax_t ) job -> id ) < 0 ) {
358+ flux_log_error (job -> h , "exec_init: flux_cmd_setenvf" );
359+ goto err ;
360+ }
354361 if (flux_cmd_argv_append (cmd , config_get_imp_path ()) < 0
355362 || flux_cmd_argv_append (cmd , "exec" ) < 0 ) {
356363 flux_log_error (job -> h , "exec_init: flux_cmd_argv_append" );
@@ -366,7 +373,7 @@ static int exec_init (struct jobinfo *job)
366373 /* If more than one shell is involved in this job, set up a channel
367374 * for exec system based barrier:
368375 */
369- if (idset_count (ranks ) > 1 ) {
376+ if (idset_count (ranks ) > 1 && ! config_use_imp_helper () ) {
370377 if (flux_cmd_add_channel (cmd , "FLUX_EXEC_PROTOCOL_FD" ) < 0
371378 || flux_cmd_setopt (cmd ,
372379 "FLUX_EXEC_PROTOCOL_FD_LINE_BUFFER" ,
0 commit comments