Skip to content

Commit

Permalink
mx_util: Rename mx_pipe_external_v to mx_pipe_external
Browse files Browse the repository at this point in the history
  • Loading branch information
donald committed May 5, 2022
1 parent 577df46 commit da60fe7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion mx_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1330,7 +1330,7 @@ static ssize_t readall(int fd, char *buf, size_t buflen) {
return len;
}

char *mx_pipe_external_v(char *helper, char **argv) {
char *mx_pipe_external(char *helper, char **argv) {
int pipefd[2];
int err;
char buf[2048];
Expand Down
2 changes: 1 addition & 1 deletion mx_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,6 @@ void _mx_sort_linked_list(void **list, int (*cmp)(void *o1,void *o2), void ** (*

unsigned long mx_df(const char *path);
time_t mx_clock_boottime(void);
char *mx_pipe_external_v(char *args, char **argv);
char *mx_pipe_external(char *args, char **argv);

#endif
8 changes: 4 additions & 4 deletions mxqd.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ static int cpuset_init(struct mxq_server *server)

static void read_hostconfig_retry(struct keywordset *kws) {
char *argv[] = { "/usr/sbin/hostconfig", NULL };
char *line = mx_pipe_external_v("/usr/sbin/hostconfig", argv);
char *line = mx_pipe_external("/usr/sbin/hostconfig", argv);
if (!line) {
mx_log_err("hostconfig: %m");
exit(1);
Expand All @@ -337,7 +337,7 @@ static char gpu_setup_script[] = LIBEXECDIR "/mxq/gpu-setup";

static int get_gpus(void) {
char *argv[] = { gpu_setup_script, "init", NULL };
char *line = mx_pipe_external_v(gpu_setup_script, argv);
char *line = mx_pipe_external(gpu_setup_script, argv);
if (!line) {
mx_log_err("gpu-setup init: %m");
exit(1);
Expand Down Expand Up @@ -910,7 +910,7 @@ static int init_child_process(struct mxq_group_list *glist, struct mxq_job *job)
mx_asprintf_forever("%u", group->user_uid),
NULL
};
char *gpu_uuid = mx_pipe_external_v(gpu_setup_script, argv);
char *gpu_uuid = mx_pipe_external(gpu_setup_script, argv);
if (!gpu_uuid) {
mx_log_err("gpu-setup job-init: %m");
exit(1);
Expand Down Expand Up @@ -2053,7 +2053,7 @@ static void release_gpu(struct mxq_server *server, struct mxq_group *group, stru
mx_asprintf_forever("%d", job->host_pid),
NULL
};
char *gpu_uuid = mx_pipe_external_v(gpu_setup_script, argv);
char *gpu_uuid = mx_pipe_external(gpu_setup_script, argv);
free(argv[2]);
if (!gpu_uuid) {
mx_log_err("gpu-setup job-release: %m");
Expand Down
14 changes: 7 additions & 7 deletions test_mx_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -529,28 +529,28 @@ static void test_mx_pipe_external(void) {

{
char *argv[] = { "/usr/bin/echo", "123", NULL };
line = mx_pipe_external_v("/usr/bin/echo", argv);
line = mx_pipe_external("/usr/bin/echo", argv);
assert(line && strcmp(line, "123") == 0);
free(line);
}

{
char *argv[] = { "/usr/bin/echo", "-n", "123", NULL };
line = mx_pipe_external_v("/usr/bin/echo", argv);
line = mx_pipe_external("/usr/bin/echo", argv);
assert(line && strcmp(line, "123") == 0);
free(line);
}

{
char *argv[] = { "/usr/bin/echo", "-ne", "123\n456\n\n", NULL };
line = mx_pipe_external_v("/usr/bin/echo", argv);
line = mx_pipe_external("/usr/bin/echo", argv);
assert(line && strcmp(line, "123\n456\n") == 0);
free(line);
}

{
char *argv[] = { "/usr/bin/true", NULL };
line = mx_pipe_external_v("/usr/bin/true", argv);
line = mx_pipe_external("/usr/bin/true", argv);
assert(line && strcmp(line, "") == 0);
free(line);
}
Expand All @@ -559,19 +559,19 @@ static void test_mx_pipe_external(void) {

{
char *argv[] = { "/usr/bin/false", NULL };
line = mx_pipe_external_v("/usr/bin/false", argv);
line = mx_pipe_external("/usr/bin/false", argv);
assert(line == NULL && errno==EPROTO);
}

{
char *argv[] = { "/usr/bin/cat", "/usr/bin/bash", NULL };
line = mx_pipe_external_v("/usr/bin/cat", argv);
line = mx_pipe_external("/usr/bin/cat", argv);
assert(line == NULL && errno==EPROTO);
}

{
char *argv[] = { "/usr/bin/yes", NULL };
line = mx_pipe_external_v("/usr/bin/yes", argv);
line = mx_pipe_external("/usr/bin/yes", argv);
assert(line == NULL && errno==EPROTO);
}
}
Expand Down

0 comments on commit da60fe7

Please sign in to comment.