From: Kevin Day <thekevinday@gmail.com>
Date: Sun, 4 Apr 2021 15:21:59 +0000 (-0500)
Subject: Update: don't use WUNTRACED | WCONTINUED by default, provide "wait".
X-Git-Tag: 0.5.3~79
X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=022a18ff1ce82ef4fa1f996296911f2ddcb5ea7f;p=fll

Update: don't use WUNTRACED | WCONTINUED by default, provide "wait".

Don't have waitpid return if child stopped or continued.
Instead, provide a "wait" property to pass to waitpid().
---

diff --git a/level_1/fl_execute/c/execute-common.h b/level_1/fl_execute/c/execute-common.h
index dbfb96c..1691908 100644
--- a/level_1/fl_execute/c/execute-common.h
+++ b/level_1/fl_execute/c/execute-common.h
@@ -27,10 +27,11 @@ extern "C" {
  *
  * If thread support is disabled in the library, then fl_execute_parameter_option_threadsafe will fallback to non-threadsafe.
  *
- * option:      accepts the bitwise options
- * environment: the environment variable name and value pairs, set to 0 to not use.
- * signals:     the set of signals the child process should or should block, set to 0 to not use.
- * data:        the data to pipe to the child process, set to 0 to not use.
+ * option:      Accepts the bitwise options
+ * wait:        Represents options passed to waitpid(), such as WUNTRACED.
+ * environment: The environment variable name and value pairs, set to 0 to not use.
+ * signals:     The set of signals the child process should or should block, set to 0 to not use.
+ * data:        The data to pipe to the child process, set to 0 to not use.
  */
 #ifndef _di_fl_execute_parameter_t_
   #define fl_execute_parameter_option_exit       0x1
@@ -40,18 +41,20 @@ extern "C" {
 
   typedef struct {
     uint8_t option;
+    int wait;
 
     const f_string_maps_t *environment;
     const f_signal_how_t *signals;
     const f_string_static_t *data;
   } fl_execute_parameter_t;
 
-  #define fl_execute_parameter_t_initialize { 0, 0, 0, 0 }
+  #define fl_execute_parameter_t_initialize { 0, 0, 0, 0, 0 }
 
-  #define fl_macro_execute_parameter_t_initialize(option, environment, signals, data) { option, environment, signals, data }
+  #define fl_macro_execute_parameter_t_initialize(option, wait, environment, signals, data) { option, wait, environment, signals, data }
 
   #define fl_macro_execute_parameter_t_clear(set) \
     set.option = 0; \
+    set.wait = 0; \
     set.environment = 0; \
     set.signals = 0; \
     set.data = 0;
diff --git a/level_2/fll_execute/c/private-execute.c b/level_2/fll_execute/c/private-execute.c
index 4669caa..76bafd0 100644
--- a/level_2/fll_execute/c/private-execute.c
+++ b/level_2/fll_execute/c/private-execute.c
@@ -318,7 +318,7 @@ extern "C" {
       }
 
       // have the parent wait for the child process to finish.
-      waitpid(id_process, (int *) result, WUNTRACED | WCONTINUED);
+      waitpid(id_process, (int *) result, parameter->wait);
 
       // this must explicitly check for 0 (as opposed to checking (!result)).
       if (result != 0) {
@@ -490,7 +490,7 @@ extern "C" {
       }
 
       // have the parent wait for the child process to finish.
-      waitpid(id_process, (int *) result, WUNTRACED | WCONTINUED);
+      waitpid(id_process, (int *) result, parameter->wait);
 
       // this must explicitly check for 0 (as opposed to checking (!result)).
       if (result != 0) {
diff --git a/level_3/fake/c/private-build.c b/level_3/fake/c/private-build.c
index 1bd31a8..4966cec 100644
--- a/level_3/fake/c/private-build.c
+++ b/level_3/fake/c/private-build.c
@@ -666,7 +666,7 @@ extern "C" {
       f_signal_set_empty(&signals.block);
       f_signal_set_fill(&signals.block_not);
 
-      fl_execute_parameter_t parameter = fl_macro_execute_parameter_t_initialize(fl_execute_parameter_option_path, &data_build.environment, &signals, 0);
+      fl_execute_parameter_t parameter = fl_macro_execute_parameter_t_initialize(fl_execute_parameter_option_path, 0, &data_build.environment, &signals, 0);
 
       *status = fll_execute_program(path.string, arguments, &parameter, 0, (void *) &return_code);
 
diff --git a/level_3/fake/c/private-fake.c b/level_3/fake/c/private-fake.c
index 9d09ae7..68e4e6a 100644
--- a/level_3/fake/c/private-fake.c
+++ b/level_3/fake/c/private-fake.c
@@ -41,7 +41,7 @@ extern "C" {
       f_signal_set_empty(&signals.block);
       f_signal_set_fill(&signals.block_not);
 
-      fl_execute_parameter_t parameter = fl_macro_execute_parameter_t_initialize(0, &environment, &signals, 0);
+      fl_execute_parameter_t parameter = fl_macro_execute_parameter_t_initialize(0, 0, &environment, &signals, 0);
 
       *status = fll_execute_program(program.string, arguments, &parameter, 0, (void *) &return_code);
 
diff --git a/level_3/fake/c/private-make.c b/level_3/fake/c/private-make.c
index 96b7497..72bd3b6 100644
--- a/level_3/fake/c/private-make.c
+++ b/level_3/fake/c/private-make.c
@@ -3815,7 +3815,7 @@ extern "C" {
     f_signal_set_empty(&signals.block);
     f_signal_set_fill(&signals.block_not);
 
-    fl_execute_parameter_t parameter = fl_macro_execute_parameter_t_initialize(as_shell ? 0 : fl_execute_parameter_option_path, &data_make->environment, &signals, 0);
+    fl_execute_parameter_t parameter = fl_macro_execute_parameter_t_initialize(as_shell ? 0 : fl_execute_parameter_option_path, 0, &data_make->environment, &signals, 0);
 
     status = fll_execute_program(program.string, arguments, &parameter, 0, (void *) &return_code);