summaryrefslogtreecommitdiffstats
path: root/runtime/staprun/mainloop.c
diff options
context:
space:
mode:
authorElliott Baron <ebaron@toriamos.yyz.redhat.com>2008-12-05 16:46:32 -0500
committerElliott Baron <ebaron@toriamos.yyz.redhat.com>2008-12-05 16:46:32 -0500
commitece3457a5cc92f0968ebf52823af2d017d5272c1 (patch)
tree45833a5ca9d552032a1d52f005d5e92e1f3ab441 /runtime/staprun/mainloop.c
parent5cf5735849650a89aa3182dfbacd8218ac0f3b9e (diff)
parent2f62657ce707b4011253d533c0423ed8d49a3e9e (diff)
downloadsystemtap-steved-ece3457a5cc92f0968ebf52823af2d017d5272c1.tar.gz
systemtap-steved-ece3457a5cc92f0968ebf52823af2d017d5272c1.tar.xz
systemtap-steved-ece3457a5cc92f0968ebf52823af2d017d5272c1.zip
Merge branch 'master'; commit 'origin/pr6925'
Diffstat (limited to 'runtime/staprun/mainloop.c')
-rw-r--r--runtime/staprun/mainloop.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/runtime/staprun/mainloop.c b/runtime/staprun/mainloop.c
index 2b044bdf..2fb049b0 100644
--- a/runtime/staprun/mainloop.c
+++ b/runtime/staprun/mainloop.c
@@ -144,7 +144,7 @@ void start_cmd(void)
{
/* The user must have used a shell metacharacter, thinking that
we use system(3) to evaluate 'stap -c CMD'. We could generate
- an error message ... but let's just do what the user meant.
+ an error message ... but let's just do what the user meant.
rhbz 467652. */
sh_c_argv[0] = "sh";
sh_c_argv[1] = "-c";
@@ -153,15 +153,15 @@ void start_cmd(void)
}
else
{
- switch (rc)
+ switch (rc)
{
- case 0:
+ case 0:
break;
case WRDE_SYNTAX:
_err ("wordexp: syntax error (unmatched quotes?) in -c COMMAND\n");
_exit(1);
default:
- _err ("wordexp: parsing error (%d)\n", rc);
+ _err ("wordexp: parsing error (%d)\n", rc);
_exit (1);
}
if (words.we_wordc < 1) { _err ("empty -c COMMAND"); _exit (1); }
@@ -356,9 +356,16 @@ void cleanup_and_exit(int detach)
if (detach) {
err("\nDisconnecting from systemtap module.\n" "To reconnect, type \"staprun -A %s\"\n", modname);
} else {
+ const char *staprun = getenv ("SYSTEMTAP_STAPRUN") ?: BINDIR "/staprun";
dbug(2, "removing %s\n", modname);
- if (execl(BINDIR "/staprun", "staprun", "-d", modname, NULL) < 0) {
- perror(modname);
+ if (execlp(staprun, basename (staprun), "-d", modname, NULL) < 0) {
+ if (errno == ENOEXEC) {
+ char *cmd;
+ if (asprintf(&cmd, "%s -d '%s'", staprun, modname) > 0)
+ execl("/bin/sh", "sh", "-c", cmd, NULL);
+ free(cmd);
+ }
+ perror(staprun);
_exit(1);
}
}