Skip to content

Commit

Permalink
Merge pull request #5699 from garlick/subprocess_cleanup
Browse files Browse the repository at this point in the history
libsubprocess: minor API cleanup
  • Loading branch information
mergify[bot] committed Mar 4, 2024
2 parents fac47c6 + 3fb5a13 commit e50ce65
Show file tree
Hide file tree
Showing 26 changed files with 199 additions and 541 deletions.
26 changes: 6 additions & 20 deletions src/common/libsubprocess/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void flux_cmd_destroy (flux_cmd_t *cmd);
* Append formatted string to argv of `cmd`.
*/
int flux_cmd_argv_appendf (flux_cmd_t *cmd,
const char *fmt, ...)
const char *fmt, ...)
__attribute__ ((format (printf, 2, 3)));

/*
Expand Down Expand Up @@ -82,10 +82,10 @@ char *flux_cmd_stringify (const flux_cmd_t *cmd);
* If `overwrite` is non-zero then overwrite any existing setting for `name`.
*/
int flux_cmd_setenvf (flux_cmd_t *cmd,
int overwrite,
int overwrite,
const char *name,
const char *fmt,
...)
const char *fmt,
...)
__attribute__ ((format (printf, 4, 5)));

/*
Expand Down Expand Up @@ -155,22 +155,6 @@ int flux_cmd_add_channel (flux_cmd_t *cmd, const char *name);
* - name + "_LINE_BUFFER" - configuring line buffering on channel name
* - stdout_LINE_BUFFER - configure line buffering for stdout
* - stderr_LINE_BUFFER - configure line buffering for stderr
*
* "STREAM_STOP" option
*
* By default, the 'on_output' callback
* can immediately begin receiving stdout/stderr data
* once a subprocess has started. There are circumstances where a
* caller may wish to wait and can have the stream stopped by
* default and restarted later by flux_subprocess_stream_start().
* By setting this option to "true", the output callback will be
* stopped by default. These options can also be set to "false" to
* keep default behavior. Note that these options only apply to
* local subprocesses.
*
* - name + "_STREAM_STOP" - configure start/stop on channel name
* - stdout_STREAM_STOP - configure start/stop for stdout
* - stderr_STREAM_STOP - configure start/stop for stderr
*/
int flux_cmd_setopt (flux_cmd_t *cmd, const char *var, const char *val);
const char *flux_cmd_getopt (flux_cmd_t *cmd, const char *var);
Expand All @@ -180,3 +164,5 @@ const char *flux_cmd_getopt (flux_cmd_t *cmd, const char *var);
#endif

#endif /* !_SUBPROCESS_COMMAND_H */

// vi: ts=4 sw=4 expandtab
2 changes: 2 additions & 0 deletions src/common/libsubprocess/command_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,5 @@ zlist_t *cmd_channel_list (flux_cmd_t *cmd);
int cmd_find_opts (const flux_cmd_t *cmd, const char **substrings);

#endif /* !_SUBPROCESS_COMMAND_PRIVATE_H */

// vi: ts=4 sw=4 expandtab
2 changes: 2 additions & 0 deletions src/common/libsubprocess/ev_fbuf_read.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,5 @@ void ev_fbuf_read_incref (struct ev_fbuf_read *ebr);
void ev_fbuf_read_decref (struct ev_fbuf_read *ebr);

#endif /* !_LIBSUBPROCESS_EV_FBUF_READ_H */

// vi: ts=4 sw=4 expandtab
2 changes: 2 additions & 0 deletions src/common/libsubprocess/ev_fbuf_write.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ void ev_fbuf_write_start (struct ev_loop *loop, struct ev_fbuf_write *ebw);
void ev_fbuf_write_stop (struct ev_loop *loop, struct ev_fbuf_write *ebw);
void ev_fbuf_write_wakeup (struct ev_fbuf_write *ebw);
#endif /* !_EV_BUFFER_WRITE_H */

// vi: ts=4 sw=4 expandtab
2 changes: 2 additions & 0 deletions src/common/libsubprocess/fbuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,5 @@ typedef void (*fbuf_notify_f) (struct fbuf *fb, void *arg);
void fbuf_set_notify (struct fbuf *fb, fbuf_notify_f cb, void *arg);

#endif /* !_LIBSUBPROCESS_FBUF_H */

// vi: ts=4 sw=4 expandtab
2 changes: 2 additions & 0 deletions src/common/libsubprocess/fork.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@
int create_process_fork (flux_subprocess_t *p);

#endif /* !_SUBPROCESS_FORK_H */

// vi: ts=4 sw=4 expandtab
12 changes: 2 additions & 10 deletions src/common/libsubprocess/local.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,17 +438,9 @@ static int start_local_watchers (flux_subprocess_t *p)

c = zhash_first (p->channels);
while (c) {
int ret;
flux_watcher_start (c->buffer_write_w);
if ((ret = cmd_option_stream_stop (p, c->name)) < 0)
return -1;
if (ret) {
flux_watcher_start (c->buffer_read_stopped_w);
}
else {
flux_watcher_start (c->buffer_read_w);
c->buffer_read_w_started = true;
}
flux_watcher_start (c->buffer_read_w);
c->buffer_read_w_started = true;
c = zhash_next (p->channels);
}
return 0;
Expand Down
2 changes: 2 additions & 0 deletions src/common/libsubprocess/local.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@
int subprocess_local_setup (flux_subprocess_t *p);

#endif /* !_SUBPROCESS_LOCAL_H */

// vi: ts=4 sw=4 expandtab
2 changes: 2 additions & 0 deletions src/common/libsubprocess/posix_spawn.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@
int create_process_spawn (flux_subprocess_t *p);

#endif /* !_SUBPROCESS_SPAWN_H */

// vi: ts=4 sw=4 expandtab
2 changes: 2 additions & 0 deletions src/common/libsubprocess/remote.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ int remote_exec (flux_subprocess_t *p);
flux_future_t *remote_kill (flux_subprocess_t *p, int signum);

#endif /* !_SUBPROCESS_REMOTE_H */

// vi: ts=4 sw=4 expandtab
4 changes: 2 additions & 2 deletions src/common/libsubprocess/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ static void server_kill (flux_subprocess_t *p, int signum);
static void proc_destructor (void **item)
{
if (item) {
flux_subprocess_unref (*item);
subprocess_decref (*item);
*item = NULL;
}
}
Expand Down Expand Up @@ -373,7 +373,7 @@ static void server_exec_cb (flux_t *h,
}
flux_cmd_destroy (cmd);
free (env);
flux_subprocess_unref (p);
subprocess_decref (p);
}

static void server_write_cb (flux_t *h,
Expand Down
2 changes: 2 additions & 0 deletions src/common/libsubprocess/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,5 @@ void subprocess_server_destroy (subprocess_server_t *s);
flux_future_t *subprocess_server_shutdown (subprocess_server_t *s, int signum);

#endif /* !_SUBPROCESS_SERVER_H */

// vi: ts=4 sw=4 expandtab

0 comments on commit e50ce65

Please sign in to comment.