Changeset 4552


Ignore:
Timestamp:
07/23/08 10:36:18 (5 years ago)
Author:
zecke
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • developers/zecke/app_restarter/app_restarter.c

    r4549 r4552  
    197197 * On any kind of exit ask the user to restart 
    198198 */ 
    199 int fork_and_exec(char* file, int argc, char** argv) 
     199int fork_and_exec(int argc, char** argv) 
    200200{ 
    201201    pid_t pid = vfork(); 
    202202 
    203203    if (pid == 0) { 
    204         execvp(file, argv); 
    205         fprintf(stderr, "Failed to launch: %s\n", file); 
     204        execvp(argv[0], argv); 
     205        fprintf(stderr, "Failed to launch: %s\n", argv[0]); 
    206206        _exit(-1); 
    207207    } else { 
    208208        int status; 
    209209 
     210        fprintf(stderr, "Waiting for pid: %d\n", pid); 
     211 
    210212        /* wait for the process to die */ 
    211213        while (waitpid(pid, &status, 0) != pid); 
     
    233235 
    234236    /* Create a list for execvp with a sentinel */ 
    235     int commands = argc-3; 
     237    int commands = argc-2; 
    236238    char** command_arguments = (char**) malloc(sizeof(char*)*(commands+1)); 
    237239    for (i = 0; i < commands; ++i) 
     
    240242 
    241243    for (;;) { 
    242         int status = fork_and_exec(argv[2], commands, command_arguments); 
     244        int status = fork_and_exec(commands, command_arguments); 
    243245        handle_crash(status, argv[1]); 
    244246    } 
Note: See TracChangeset for help on using the changeset viewer.