Stéphane Graber has proposed merging lp:~stgraber/upstart/upstart-fix-respawn
into lp:upstart.
Requested reviews:
Upstart Reviewers (upstart-reviewers)
For more details, see:
https://code.launchpad.net/~stgraber/upstart/upstart-fix-respawn/+merge/172420
This fixes a regression recently found when working on Ubuntu Touch.
The problem is that if a job has the respawn flag and doesn't contain any of
the standard shell characters in its exec line, upstart will still set
job->script to TRUE once the initial run has succeeded. This mean that on first
respawn of the job, it'll end up forking one extra time and confuse upstart.
The change that introduced this was done to fix a case where tests would fail
when running from a directory containing a shell character in its name (~test
for example). The assumption at the time being that ->script wasn't persistent
(clearly wrong) and that it wouldn't hurt to set it after the job has been
started in order to simplify testing.
The fix is to revert the change to upstart itself and instead include the same
shell characters list in the testsuite and have the testsuite check against it
just like init itself does.
--
https://code.launchpad.net/~stgraber/upstart/upstart-fix-respawn/+merge/172420
Your team Upstart Reviewers is requested to review the proposed merge of
lp:~stgraber/upstart/upstart-fix-respawn into lp:upstart.
=== modified file 'init/job_process.c'
--- init/job_process.c 2013-05-31 15:34:00 +0000
+++ init/job_process.c 2013-07-01 21:10:33 +0000
@@ -261,12 +261,6 @@
NIH_MUST (nih_str_array_addp (&argv, NULL,
&argc, cmd));
}
-
- /* At the end, always set proc->script to TRUE, even if the user didn't
- * explicitly set it (when using shell variables). That way tests
- * can reliably check for shell-specific behaviour.
- */
- proc->script = TRUE;
} else {
/* Split the command on whitespace to produce a list of
* arguments that we can exec directly.
=== modified file 'init/tests/test_job_process.c'
--- init/tests/test_job_process.c 2013-06-25 09:19:05 +0000
+++ init/tests/test_job_process.c 2013-07-01 21:10:33 +0000
@@ -83,6 +83,14 @@
#define MAX_ITERATIONS 5
/**
+ * SHELL_CHARS:
+ *
+ * This is the list of characters that, if encountered in a process, cause
+ * it to always be run with a shell.
+ **/
+#define SHELL_CHARS "~`!$^&*()=|\\{}[];\"'<>?"
+
+/**
* CHECK_FILE_EQ:
*
* @_file: FILE to read from,
@@ -677,7 +685,7 @@
output = fopen (filename, "r");
TEST_FILE_EQ (output, "BAR=BAZ\n");
TEST_FILE_EQ (output, "FOO=BAR\n");
- if (job->class->process[PROCESS_MAIN]->script)
+ if (job->class->process[PROCESS_MAIN]->script || strpbrk (job->class->process[PROCESS_MAIN]->command, SHELL_CHARS))
TEST_FILE_EQ (output, "PWD=/\n");
TEST_FILE_EQ (output, "UPSTART_INSTANCE=\n");
TEST_FILE_EQ (output, "UPSTART_JOB=test\n");
@@ -733,7 +741,7 @@
output = fopen (filename, "r");
TEST_FILE_EQ (output, "BAR=BAZ\n");
TEST_FILE_EQ (output, "FOO=BAR\n");
- if (job->class->process[PROCESS_MAIN]->script)
+ if (job->class->process[PROCESS_MAIN]->script || strpbrk (job->class->process[PROCESS_MAIN]->command, SHELL_CHARS))
TEST_FILE_EQ (output, "PWD=/\n");
TEST_FILE_EQ (output, "UPSTART_INSTANCE=foo\n");
TEST_FILE_EQ (output, "UPSTART_JOB=test\n");
@@ -791,7 +799,7 @@
TEST_FILE_EQ (output, "BAR=BAZ\n");
TEST_FILE_EQ (output, "CRACKLE=FIZZ\n");
TEST_FILE_EQ (output, "FOO=SMACK\n");
- if (job->class->process[PROCESS_PRE_STOP]->script)
+ if (job->class->process[PROCESS_PRE_STOP]->script || strpbrk (job->class->process[PROCESS_PRE_STOP]->command, SHELL_CHARS))
TEST_FILE_EQ (output, "PWD=/\n");
TEST_FILE_EQ (output, "UPSTART_INSTANCE=\n");
TEST_FILE_EQ (output, "UPSTART_JOB=test\n");
@@ -849,7 +857,7 @@
TEST_FILE_EQ (output, "BAR=BAZ\n");
TEST_FILE_EQ (output, "CRACKLE=FIZZ\n");
TEST_FILE_EQ (output, "FOO=SMACK\n");
- if (job->class->process[PROCESS_POST_STOP]->script)
+ if (job->class->process[PROCESS_POST_STOP]->script || strpbrk (job->class->process[PROCESS_POST_STOP]->command, SHELL_CHARS))
TEST_FILE_EQ (output, "PWD=/\n");
TEST_FILE_EQ (output, "UPSTART_INSTANCE=\n");
TEST_FILE_EQ (output, "UPSTART_JOB=test\n");
--
upstart-devel mailing list
[email protected]
Modify settings or unsubscribe at:
https://lists.ubuntu.com/mailman/listinfo/upstart-devel