r4552 - developers/zecke/app_restarter
zecke at docs.openmoko.org
zecke at docs.openmoko.org
Wed Jul 23 10:36:20 CEST 2008
Author: zecke
Date: 2008-07-23 10:36:18 +0200 (Wed, 23 Jul 2008)
New Revision: 4552
Modified:
developers/zecke/app_restarter/app_restarter.c
Log:
app_restarter: Make sure that argv[0] is the app we want to execute...
Stupid oversight. argv[0] is supposed to the command name of the
application.
Modified: developers/zecke/app_restarter/app_restarter.c
===================================================================
--- developers/zecke/app_restarter/app_restarter.c 2008-07-23 02:27:05 UTC (rev 4551)
+++ developers/zecke/app_restarter/app_restarter.c 2008-07-23 08:36:18 UTC (rev 4552)
@@ -196,17 +196,19 @@
* Fork and execute the command, wait for the command to finish.
* On any kind of exit ask the user to restart
*/
-int fork_and_exec(char* file, int argc, char** argv)
+int fork_and_exec(int argc, char** argv)
{
pid_t pid = vfork();
if (pid == 0) {
- execvp(file, argv);
- fprintf(stderr, "Failed to launch: %s\n", file);
+ execvp(argv[0], argv);
+ fprintf(stderr, "Failed to launch: %s\n", argv[0]);
_exit(-1);
} else {
int status;
+ fprintf(stderr, "Waiting for pid: %d\n", pid);
+
/* wait for the process to die */
while (waitpid(pid, &status, 0) != pid);
@@ -232,14 +234,14 @@
}
/* Create a list for execvp with a sentinel */
- int commands = argc-3;
+ int commands = argc-2;
char** command_arguments = (char**) malloc(sizeof(char*)*(commands+1));
for (i = 0; i < commands; ++i)
command_arguments[i] = argv[2+i];
command_arguments[commands] = NULL;
for (;;) {
- int status = fork_and_exec(argv[2], commands, command_arguments);
+ int status = fork_and_exec(commands, command_arguments);
handle_crash(status, argv[1]);
}
}
More information about the commitlog
mailing list