diff --git a/toolkit/mozapps/update/src/updater/updater.cpp b/toolkit/mozapps/update/src/updater/updater.cpp index 72e8378f7a45..fcbce1112d16 100644 --- a/toolkit/mozapps/update/src/updater/updater.cpp +++ b/toolkit/mozapps/update/src/updater/updater.cpp @@ -1185,31 +1185,33 @@ int NS_main(int argc, NS_tchar **argv) // necessary for the parent process to exit before its executable image may // be altered. - if (argc < 3) { - fprintf(stderr, "Usage: updater [working-dir callback args...]\n"); + if (argc < 2) { + fprintf(stderr, "Usage: updater [parent-pid [working-dir callback args...]]\n"); return 1; } - int pid = NS_tatoi(argv[2]); - if (pid) { + if (argc > 2 ) { + int pid = NS_tatoi(argv[2]); + if (pid) { #ifdef XP_WIN - HANDLE parent = OpenProcess(SYNCHRONIZE, FALSE, (DWORD) pid); - // May return NULL if the parent process has already gone away. - // Otherwise, wait for the parent process to exit before starting the - // update. - if (parent) { - DWORD result = WaitForSingleObject(parent, 5000); - CloseHandle(parent); - if (result != WAIT_OBJECT_0) - return 1; - // The process may be signaled before it releases the executable image. - // This is a terrible hack, but it'll have to do for now :-( - Sleep(50); - } + HANDLE parent = OpenProcess(SYNCHRONIZE, FALSE, (DWORD) pid); + // May return NULL if the parent process has already gone away. + // Otherwise, wait for the parent process to exit before starting the + // update. + if (parent) { + DWORD result = WaitForSingleObject(parent, 5000); + CloseHandle(parent); + if (result != WAIT_OBJECT_0) + return 1; + // The process may be signaled before it releases the executable image. + // This is a terrible hack, but it'll have to do for now :-( + Sleep(50); + } #else - int status; - waitpid(pid, &status, 0); + int status; + waitpid(pid, &status, 0); #endif + } } #ifdef XP_WIN