aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-07-17 22:35:36 +0200
committerChristian Grothoff <christian@grothoff.org>2020-07-17 22:35:36 +0200
commit28ab2c446fba4980a8295d59fdf203a028a35dd6 (patch)
treeebd266d1e280e353e8857a7e3e35bbf609c0a888 /src/util
parent931232d1141891232e46f5d6fd1432663e730e7a (diff)
downloadgnunet-28ab2c446fba4980a8295d59fdf203a028a35dd6.tar.gz
gnunet-28ab2c446fba4980a8295d59fdf203a028a35dd6.zip
avoid boolean flag in GNUNET_OS_start_process() API (fixes #6188)
Diffstat (limited to 'src/util')
-rw-r--r--src/util/gnunet-qr.c3
-rw-r--r--src/util/gnunet-uri.c3
-rw-r--r--src/util/helper.c5
-rw-r--r--src/util/os_priority.c50
-rw-r--r--src/util/test_common_logging_runtime_loglevels.c2
-rw-r--r--src/util/test_os_start_process.c8
-rw-r--r--src/util/test_resolver_api.c4
7 files changed, 32 insertions, 43 deletions
diff --git a/src/util/gnunet-qr.c b/src/util/gnunet-qr.c
index cd23c3a9c..84a3184bc 100644
--- a/src/util/gnunet-qr.c
+++ b/src/util/gnunet-qr.c
@@ -192,8 +192,7 @@ gnunet_uri (void *cls,
192 GNUNET_array_append (argv, 192 GNUNET_array_append (argv,
193 argc, 193 argc,
194 NULL); 194 NULL);
195 p = GNUNET_OS_start_process_vap (GNUNET_NO, 195 p = GNUNET_OS_start_process_vap (GNUNET_OS_INHERIT_STD_ALL,
196 GNUNET_OS_INHERIT_STD_ALL,
197 NULL, 196 NULL,
198 NULL, 197 NULL,
199 NULL, 198 NULL,
diff --git a/src/util/gnunet-uri.c b/src/util/gnunet-uri.c
index 48c46ee49..f8754a6d1 100644
--- a/src/util/gnunet-uri.c
+++ b/src/util/gnunet-uri.c
@@ -115,8 +115,7 @@ run (void *cls,
115 GNUNET_DISK_pipe_handle (sigpipe, GNUNET_DISK_PIPE_END_READ), 115 GNUNET_DISK_pipe_handle (sigpipe, GNUNET_DISK_PIPE_END_READ),
116 &maint_child_death, 116 &maint_child_death,
117 NULL); 117 NULL);
118 p = GNUNET_OS_start_process (GNUNET_NO, 118 p = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_NONE,
119 0,
120 NULL, 119 NULL,
121 NULL, 120 NULL,
122 NULL, 121 NULL,
diff --git a/src/util/helper.c b/src/util/helper.c
index 8c8fb7b6a..7985f2eca 100644
--- a/src/util/helper.c
+++ b/src/util/helper.c
@@ -422,8 +422,9 @@ start_helper (struct GNUNET_HELPER_Handle *h)
422 GNUNET_DISK_pipe_handle (h->helper_out, GNUNET_DISK_PIPE_END_READ); 422 GNUNET_DISK_pipe_handle (h->helper_out, GNUNET_DISK_PIPE_END_READ);
423 h->fh_to_helper = 423 h->fh_to_helper =
424 GNUNET_DISK_pipe_handle (h->helper_in, GNUNET_DISK_PIPE_END_WRITE); 424 GNUNET_DISK_pipe_handle (h->helper_in, GNUNET_DISK_PIPE_END_WRITE);
425 h->helper_proc = GNUNET_OS_start_process_vap (h->with_control_pipe, 425 h->helper_proc = GNUNET_OS_start_process_vap (h->with_control_pipe
426 GNUNET_OS_INHERIT_STD_ERR, 426 ? GNUNET_OS_INHERIT_STD_ERR | GNUNET_OS_USE_PIPE_CONTROL
427 : GNUNET_OS_INHERIT_STD_ERR,
427 h->helper_in, 428 h->helper_in,
428 h->helper_out, 429 h->helper_out,
429 NULL, 430 NULL,
diff --git a/src/util/os_priority.c b/src/util/os_priority.c
index 7f3be2a80..2f86f792f 100644
--- a/src/util/os_priority.c
+++ b/src/util/os_priority.c
@@ -326,7 +326,6 @@ open_dev_null (int target_fd, int flags)
326/** 326/**
327 * Start a process. 327 * Start a process.
328 * 328 *
329 * @param pipe_control should a pipe be used to send signals to the child?
330 * @param std_inheritance a set of GNUNET_OS_INHERIT_STD_* flags controlling which 329 * @param std_inheritance a set of GNUNET_OS_INHERIT_STD_* flags controlling which
331 * std handles of the parent are inherited by the child. 330 * std handles of the parent are inherited by the child.
332 * pipe_stdin and pipe_stdout take priority over std_inheritance 331 * pipe_stdin and pipe_stdout take priority over std_inheritance
@@ -341,8 +340,7 @@ open_dev_null (int target_fd, int flags)
341 * @return process ID of the new process, -1 on error 340 * @return process ID of the new process, -1 on error
342 */ 341 */
343static struct GNUNET_OS_Process * 342static struct GNUNET_OS_Process *
344start_process (int pipe_control, 343start_process (enum GNUNET_OS_InheritStdioFlags std_inheritance,
345 enum GNUNET_OS_InheritStdioFlags std_inheritance,
346 struct GNUNET_DISK_PipeHandle *pipe_stdin, 344 struct GNUNET_DISK_PipeHandle *pipe_stdin,
347 struct GNUNET_DISK_PipeHandle *pipe_stdout, 345 struct GNUNET_DISK_PipeHandle *pipe_stdout,
348 struct GNUNET_DISK_PipeHandle *pipe_stderr, 346 struct GNUNET_DISK_PipeHandle *pipe_stderr,
@@ -373,7 +371,7 @@ start_process (int pipe_control,
373 if (GNUNET_SYSERR == 371 if (GNUNET_SYSERR ==
374 GNUNET_OS_check_helper_binary (filename, GNUNET_NO, NULL)) 372 GNUNET_OS_check_helper_binary (filename, GNUNET_NO, NULL))
375 return NULL; /* not executable */ 373 return NULL; /* not executable */
376 if (GNUNET_YES == pipe_control) 374 if (0 != (std_inheritance & GNUNET_OS_USE_PIPE_CONTROL))
377 { 375 {
378 struct GNUNET_DISK_PipeHandle *childpipe; 376 struct GNUNET_DISK_PipeHandle *childpipe;
379 int dup_childpipe_read_fd = -1; 377 int dup_childpipe_read_fd = -1;
@@ -486,7 +484,7 @@ start_process (int pipe_control,
486 gnunet_proc = GNUNET_new (struct GNUNET_OS_Process); 484 gnunet_proc = GNUNET_new (struct GNUNET_OS_Process);
487 gnunet_proc->pid = ret; 485 gnunet_proc->pid = ret;
488 gnunet_proc->control_pipe = childpipe_write; 486 gnunet_proc->control_pipe = childpipe_write;
489 if (GNUNET_YES == pipe_control) 487 if (0 != (std_inheritance & GNUNET_OS_USE_PIPE_CONTROL))
490 { 488 {
491 close (childpipe_read_fd); 489 close (childpipe_read_fd);
492 } 490 }
@@ -594,7 +592,6 @@ start_process (int pipe_control,
594/** 592/**
595 * Start a process. 593 * Start a process.
596 * 594 *
597 * @param pipe_control should a pipe be used to send signals to the child?
598 * @param std_inheritance a set of GNUNET_OS_INHERIT_STD_* flags 595 * @param std_inheritance a set of GNUNET_OS_INHERIT_STD_* flags
599 * @param pipe_stdin pipe to use to send input to child process (or NULL) 596 * @param pipe_stdin pipe to use to send input to child process (or NULL)
600 * @param pipe_stdout pipe to use to get output from child process (or NULL) 597 * @param pipe_stdout pipe to use to get output from child process (or NULL)
@@ -604,16 +601,14 @@ start_process (int pipe_control,
604 * @return pointer to process structure of the new process, NULL on error 601 * @return pointer to process structure of the new process, NULL on error
605 */ 602 */
606struct GNUNET_OS_Process * 603struct GNUNET_OS_Process *
607GNUNET_OS_start_process_vap (int pipe_control, 604GNUNET_OS_start_process_vap (enum GNUNET_OS_InheritStdioFlags std_inheritance,
608 enum GNUNET_OS_InheritStdioFlags std_inheritance,
609 struct GNUNET_DISK_PipeHandle *pipe_stdin, 605 struct GNUNET_DISK_PipeHandle *pipe_stdin,
610 struct GNUNET_DISK_PipeHandle *pipe_stdout, 606 struct GNUNET_DISK_PipeHandle *pipe_stdout,
611 struct GNUNET_DISK_PipeHandle *pipe_stderr, 607 struct GNUNET_DISK_PipeHandle *pipe_stderr,
612 const char *filename, 608 const char *filename,
613 char *const argv[]) 609 char *const argv[])
614{ 610{
615 return start_process (pipe_control, 611 return start_process (std_inheritance,
616 std_inheritance,
617 pipe_stdin, 612 pipe_stdin,
618 pipe_stdout, 613 pipe_stdout,
619 pipe_stderr, 614 pipe_stderr,
@@ -626,7 +621,6 @@ GNUNET_OS_start_process_vap (int pipe_control,
626/** 621/**
627 * Start a process. 622 * Start a process.
628 * 623 *
629 * @param pipe_control should a pipe be used to send signals to the child?
630 * @param std_inheritance a set of GNUNET_OS_INHERIT_STD_* flags 624 * @param std_inheritance a set of GNUNET_OS_INHERIT_STD_* flags
631 * @param pipe_stdin pipe to use to send input to child process (or NULL) 625 * @param pipe_stdin pipe to use to send input to child process (or NULL)
632 * @param pipe_stdout pipe to use to get output from child process (or NULL) 626 * @param pipe_stdout pipe to use to get output from child process (or NULL)
@@ -636,8 +630,7 @@ GNUNET_OS_start_process_vap (int pipe_control,
636 * @return pointer to process structure of the new process, NULL on error 630 * @return pointer to process structure of the new process, NULL on error
637 */ 631 */
638struct GNUNET_OS_Process * 632struct GNUNET_OS_Process *
639GNUNET_OS_start_process_va (int pipe_control, 633GNUNET_OS_start_process_va (enum GNUNET_OS_InheritStdioFlags std_inheritance,
640 enum GNUNET_OS_InheritStdioFlags std_inheritance,
641 struct GNUNET_DISK_PipeHandle *pipe_stdin, 634 struct GNUNET_DISK_PipeHandle *pipe_stdin,
642 struct GNUNET_DISK_PipeHandle *pipe_stdout, 635 struct GNUNET_DISK_PipeHandle *pipe_stdout,
643 struct GNUNET_DISK_PipeHandle *pipe_stderr, 636 struct GNUNET_DISK_PipeHandle *pipe_stderr,
@@ -660,8 +653,7 @@ GNUNET_OS_start_process_va (int pipe_control,
660 while (NULL != (argv[argc] = va_arg (ap, char *))) 653 while (NULL != (argv[argc] = va_arg (ap, char *)))
661 argc++; 654 argc++;
662 va_end (ap); 655 va_end (ap);
663 ret = GNUNET_OS_start_process_vap (pipe_control, 656 ret = GNUNET_OS_start_process_vap (std_inheritance,
664 std_inheritance,
665 pipe_stdin, 657 pipe_stdin,
666 pipe_stdout, 658 pipe_stdout,
667 pipe_stderr, 659 pipe_stderr,
@@ -675,7 +667,6 @@ GNUNET_OS_start_process_va (int pipe_control,
675/** 667/**
676 * Start a process. 668 * Start a process.
677 * 669 *
678 * @param pipe_control should a pipe be used to send signals to the child?
679 * @param std_inheritance a set of GNUNET_OS_INHERIT_STD_* flags 670 * @param std_inheritance a set of GNUNET_OS_INHERIT_STD_* flags
680 * @param pipe_stdin pipe to use to send input to child process (or NULL) 671 * @param pipe_stdin pipe to use to send input to child process (or NULL)
681 * @param pipe_stdout pipe to use to get output from child process (or NULL) 672 * @param pipe_stdout pipe to use to get output from child process (or NULL)
@@ -684,8 +675,7 @@ GNUNET_OS_start_process_va (int pipe_control,
684 * @return pointer to process structure of the new process, NULL on error 675 * @return pointer to process structure of the new process, NULL on error
685 */ 676 */
686struct GNUNET_OS_Process * 677struct GNUNET_OS_Process *
687GNUNET_OS_start_process (int pipe_control, 678GNUNET_OS_start_process (enum GNUNET_OS_InheritStdioFlags std_inheritance,
688 enum GNUNET_OS_InheritStdioFlags std_inheritance,
689 struct GNUNET_DISK_PipeHandle *pipe_stdin, 679 struct GNUNET_DISK_PipeHandle *pipe_stdin,
690 struct GNUNET_DISK_PipeHandle *pipe_stdout, 680 struct GNUNET_DISK_PipeHandle *pipe_stdout,
691 struct GNUNET_DISK_PipeHandle *pipe_stderr, 681 struct GNUNET_DISK_PipeHandle *pipe_stderr,
@@ -696,8 +686,7 @@ GNUNET_OS_start_process (int pipe_control,
696 va_list ap; 686 va_list ap;
697 687
698 va_start (ap, filename); 688 va_start (ap, filename);
699 ret = GNUNET_OS_start_process_va (pipe_control, 689 ret = GNUNET_OS_start_process_va (std_inheritance,
700 std_inheritance,
701 pipe_stdin, 690 pipe_stdin,
702 pipe_stdout, 691 pipe_stdout,
703 pipe_stderr, 692 pipe_stderr,
@@ -711,7 +700,6 @@ GNUNET_OS_start_process (int pipe_control,
711/** 700/**
712 * Start a process. 701 * Start a process.
713 * 702 *
714 * @param pipe_control should a pipe be used to send signals to the child?
715 * @param std_inheritance a set of GNUNET_OS_INHERIT_STD_* flags controlling which 703 * @param std_inheritance a set of GNUNET_OS_INHERIT_STD_* flags controlling which
716 * std handles of the parent are inherited by the child. 704 * std handles of the parent are inherited by the child.
717 * pipe_stdin and pipe_stdout take priority over std_inheritance 705 * pipe_stdin and pipe_stdout take priority over std_inheritance
@@ -723,14 +711,12 @@ GNUNET_OS_start_process (int pipe_control,
723 * @return process ID of the new process, -1 on error 711 * @return process ID of the new process, -1 on error
724 */ 712 */
725struct GNUNET_OS_Process * 713struct GNUNET_OS_Process *
726GNUNET_OS_start_process_v (int pipe_control, 714GNUNET_OS_start_process_v (enum GNUNET_OS_InheritStdioFlags std_inheritance,
727 enum GNUNET_OS_InheritStdioFlags std_inheritance,
728 const int *lsocks, 715 const int *lsocks,
729 const char *filename, 716 const char *filename,
730 char *const argv[]) 717 char *const argv[])
731{ 718{
732 return start_process (pipe_control, 719 return start_process (std_inheritance,
733 std_inheritance,
734 NULL, 720 NULL,
735 NULL, 721 NULL,
736 NULL, 722 NULL,
@@ -747,7 +733,6 @@ GNUNET_OS_start_process_v (int pipe_control,
747 * in the order they appear. Arguments containing spaces can be used by 733 * in the order they appear. Arguments containing spaces can be used by
748 * quoting them with @em ". 734 * quoting them with @em ".
749 * 735 *
750 * @param pipe_control should a pipe be used to send signals to the child?
751 * @param std_inheritance a set of GNUNET_OS_INHERIT_STD_* flags 736 * @param std_inheritance a set of GNUNET_OS_INHERIT_STD_* flags
752 * @param lsocks array of listen sockets to dup systemd-style (or NULL); 737 * @param lsocks array of listen sockets to dup systemd-style (or NULL);
753 * must be NULL on platforms where dup is not supported 738 * must be NULL on platforms where dup is not supported
@@ -759,8 +744,7 @@ GNUNET_OS_start_process_v (int pipe_control,
759 * @return pointer to process structure of the new process, NULL on error 744 * @return pointer to process structure of the new process, NULL on error
760 */ 745 */
761struct GNUNET_OS_Process * 746struct GNUNET_OS_Process *
762GNUNET_OS_start_process_s (int pipe_control, 747GNUNET_OS_start_process_s (enum GNUNET_OS_InheritStdioFlags std_inheritance,
763 enum GNUNET_OS_InheritStdioFlags std_inheritance,
764 const int *lsocks, 748 const int *lsocks,
765 const char *filename, 749 const char *filename,
766 ...) 750 ...)
@@ -869,8 +853,7 @@ GNUNET_OS_start_process_s (int pipe_control,
869 } 853 }
870 } 854 }
871 binary_path = argv[0]; 855 binary_path = argv[0];
872 proc = GNUNET_OS_start_process_v (pipe_control, 856 proc = GNUNET_OS_start_process_v (std_inheritance,
873 std_inheritance,
874 lsocks, 857 lsocks,
875 binary_path, 858 binary_path,
876 argv); 859 argv);
@@ -1175,7 +1158,12 @@ GNUNET_OS_command_run (GNUNET_OS_LineProcessor proc,
1175 va_start (ap, binary); 1158 va_start (ap, binary);
1176 /* redirect stdout, don't inherit stderr/stdin */ 1159 /* redirect stdout, don't inherit stderr/stdin */
1177 eip = 1160 eip =
1178 GNUNET_OS_start_process_va (GNUNET_NO, 0, NULL, opipe, NULL, binary, ap); 1161 GNUNET_OS_start_process_va (GNUNET_OS_INHERIT_STD_NONE,
1162 NULL,
1163 opipe,
1164 NULL,
1165 binary,
1166 ap);
1179 va_end (ap); 1167 va_end (ap);
1180 if (NULL == eip) 1168 if (NULL == eip)
1181 { 1169 {
diff --git a/src/util/test_common_logging_runtime_loglevels.c b/src/util/test_common_logging_runtime_loglevels.c
index e6d83d52c..ce1cdadd6 100644
--- a/src/util/test_common_logging_runtime_loglevels.c
+++ b/src/util/test_common_logging_runtime_loglevels.c
@@ -403,7 +403,7 @@ runone ()
403 break; 403 break;
404 } 404 }
405 405
406 proc = GNUNET_OS_start_process (GNUNET_NO, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, 406 proc = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
407 NULL, pipe_stdout, NULL, 407 NULL, pipe_stdout, NULL,
408 "./test_common_logging_dummy", 408 "./test_common_logging_dummy",
409 "test_common_logging_dummy", NULL); 409 "test_common_logging_dummy", NULL);
diff --git a/src/util/test_os_start_process.c b/src/util/test_os_start_process.c
index 2bdca5c9d..6d4a131bb 100644
--- a/src/util/test_os_start_process.c
+++ b/src/util/test_os_start_process.c
@@ -138,7 +138,7 @@ run_task (void *cls)
138 } 138 }
139 139
140 proc = 140 proc =
141 GNUNET_OS_start_process (GNUNET_NO, GNUNET_OS_INHERIT_STD_ERR, 141 GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ERR,
142 hello_pipe_stdin, hello_pipe_stdout, NULL, 142 hello_pipe_stdin, hello_pipe_stdout, NULL,
143 fn, 143 fn,
144 "test_gnunet_echo_hello", "-", NULL); 144 "test_gnunet_echo_hello", "-", NULL);
@@ -212,7 +212,8 @@ check_kill ()
212 } 212 }
213 fn = GNUNET_OS_get_libexec_binary_path ("gnunet-service-resolver"); 213 fn = GNUNET_OS_get_libexec_binary_path ("gnunet-service-resolver");
214 proc = 214 proc =
215 GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_ERR, 215 GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ERR
216 | GNUNET_OS_USE_PIPE_CONTROL,
216 hello_pipe_stdin, 217 hello_pipe_stdin,
217 hello_pipe_stdout, 218 hello_pipe_stdout,
218 NULL, 219 NULL,
@@ -256,7 +257,8 @@ check_instant_kill ()
256 } 257 }
257 fn = GNUNET_OS_get_libexec_binary_path ("gnunet-service-resolver"); 258 fn = GNUNET_OS_get_libexec_binary_path ("gnunet-service-resolver");
258 proc = 259 proc =
259 GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_ERR, 260 GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ERR
261 | GNUNET_OS_USE_PIPE_CONTROL,
260 hello_pipe_stdin, hello_pipe_stdout, NULL, 262 hello_pipe_stdin, hello_pipe_stdout, NULL,
261 fn, 263 fn,
262 "gnunet-service-resolver", "-", NULL); 264 "gnunet-service-resolver", "-", NULL);
diff --git a/src/util/test_resolver_api.c b/src/util/test_resolver_api.c
index 05716741e..eefb20890 100644
--- a/src/util/test_resolver_api.c
+++ b/src/util/test_resolver_api.c
@@ -348,8 +348,8 @@ main (int argc, char *argv[])
348 "WARNING", 348 "WARNING",
349 NULL); 349 NULL);
350 fn = GNUNET_OS_get_libexec_binary_path ("gnunet-service-resolver"); 350 fn = GNUNET_OS_get_libexec_binary_path ("gnunet-service-resolver");
351 proc = GNUNET_OS_start_process (GNUNET_YES, 351 proc = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_OUT_AND_ERR
352 GNUNET_OS_INHERIT_STD_OUT_AND_ERR, 352 | GNUNET_OS_USE_PIPE_CONTROL,
353 NULL, NULL, NULL, 353 NULL, NULL, NULL,
354 fn, 354 fn,
355 "gnunet-service-resolver", 355 "gnunet-service-resolver",