summaryrefslogtreecommitdiffabout
path: root/src
authorSergey Poznyakoff <gray@gnu.org>2019-06-03 10:17:13 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2019-06-03 10:41:34 (GMT)
commitf50a208f9df348cede2ba50b4f435351d8d3f19e (patch) (side-by-side diff)
treec596fdf237b17713ab56c0269cdb1d339e306941 /src
parent8004bbaa1b31b14dd4c4d3886b5f57b103bf7405 (diff)
downloadpies-f50a208f9df348cede2ba50b4f435351d8d3f19e.tar.gz
pies-f50a208f9df348cede2ba50b4f435351d8d3f19e.tar.bz2
Finish the env re-implementation
* NEWS: Document the "env" statement and the PIES_MASTER_PID environment variable. Version 1.3.91 * configure.ac: Version 1.3.91 * doc/pies.texi: Document the new "env" statement syntax. Provide instructions on how to convert legacy "env" statement to the new form. * lib/envop.c (environ_unset): Take reference value as argument. If supplied, unset the variable only if its value matches the reference one. * lib/envop.h (environ_unset): Change proto. * src/pies.c (parse_legacy_env): Minor changes. (_cb_env_unset): Allow to specify value. * src/progman.c (run_command): Define PIES_MASTER_PID. * tests/env.at: Check the legacy env syntax. * tests/envop.at: Additional checks.
Diffstat (limited to 'src') (more/less context) (ignore whitespace changes)
-rw-r--r--src/pies.c10
-rw-r--r--src/progman.c7
2 files changed, 12 insertions, 5 deletions
diff --git a/src/pies.c b/src/pies.c
index 2387cef..fe8d9b4 100644
--- a/src/pies.c
+++ b/src/pies.c
@@ -613,7 +613,7 @@ parse_legacy_env (char **argv, envop_t **envop)
{
msize = 2*len + 9 + vlen + 1;
mem = grecs_malloc (msize);
- snprintf (mem, msize, "${%s:-}${%s+%c}%s",
+ snprintf (mem, msize, "${%s:-}${%s:+%c}%s",
name, name, value[0], value + 1);
}
else
@@ -635,7 +635,7 @@ parse_legacy_env (char **argv, envop_t **envop)
msize = 2*len + 10 + vlen + 1;
mem = grecs_malloc (msize);
- snprintf (mem, msize, "%s${%s+%c}${%s:-}",
+ snprintf (mem, msize, "%s${%s:+%c}${%s:-}",
value, name, c, name);
}
else
@@ -785,11 +785,15 @@ _cb_env_unset (enum grecs_callback_command cmd,
void *varptr, grecs_value_t *value, void *cb_data)
{
struct component *comp = varptr;
+ char *p;
if (assert_scalar_stmt (locus, cmd)
|| assert_grecs_value_type (locus, value, GRECS_TYPE_STRING))
return 1;
- if (envop_entry_add (&comp->envop, envop_unset, value->v.string, NULL))
+ p = strchr (value->v.string, '=');
+ if (p)
+ *p++ = 0;
+ if (envop_entry_add (&comp->envop, envop_unset, value->v.string, p))
grecs_error (locus, errno, "envop_entry_add");
return 0;
}
diff --git a/src/progman.c b/src/progman.c
index b75a2db..a6dc418 100644
--- a/src/progman.c
+++ b/src/progman.c
@@ -821,7 +821,7 @@ prog_start_prologue (struct prog *prog)
{
size_t i;
for (i = 0; sockenv_var[i]; i++)
- environ_unset (prog->v.p.env, sockenv_var[i]);
+ environ_unset (prog->v.p.env, sockenv_var[i], NULL);
}
envop_exec (prog->v.p.comp->envop, prog->v.p.env);
if (init_process)
@@ -1978,10 +1978,12 @@ static void
run_command (struct action *act, struct prog *prog, unsigned retcode,
pid_t child_pid)
{
- pid_t pid;
+ pid_t pid, master_pid;
char *argv[4];
char buf[INT_BUFSIZE_BOUND (uintmax_t)];
+ master_pid = getpid ();
+
/* FIXME: optionally set output redirectors for this command? */
pid = fork ();
@@ -1998,6 +2000,7 @@ run_command (struct action *act, struct prog *prog, unsigned retcode,
setsid ();
setenv ("PIES_VERSION", PACKAGE_VERSION, 1);
setenv ("PIES_COMPONENT", prog_tag (prog), 1);
+ setenv ("PIES_MASTER_PID", umaxtostr (master_pid, buf), 1);
setenv ("PIES_PID", umaxtostr (child_pid, buf), 1);
if (retcode & STATUS_SIG_BIT)
setenv ("PIES_SIGNAL", umaxtostr (STATUS_CODE (retcode), buf), 1);

Return to:

Send suggestions and report system problems to the System administrator.