mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-13 11:38:16 +00:00
Bug 452174 - Make updater binary parent-pid command line arg optional. r=bsmedberg
This commit is contained in:
parent
65ef12c84a
commit
f54c209e31
@ -1185,31 +1185,33 @@ int NS_main(int argc, NS_tchar **argv)
|
|||||||
// necessary for the parent process to exit before its executable image may
|
// necessary for the parent process to exit before its executable image may
|
||||||
// be altered.
|
// be altered.
|
||||||
|
|
||||||
if (argc < 3) {
|
if (argc < 2) {
|
||||||
fprintf(stderr, "Usage: updater <dir-path> <parent-pid> [working-dir callback args...]\n");
|
fprintf(stderr, "Usage: updater <dir-path> [parent-pid [working-dir callback args...]]\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pid = NS_tatoi(argv[2]);
|
if (argc > 2 ) {
|
||||||
if (pid) {
|
int pid = NS_tatoi(argv[2]);
|
||||||
|
if (pid) {
|
||||||
#ifdef XP_WIN
|
#ifdef XP_WIN
|
||||||
HANDLE parent = OpenProcess(SYNCHRONIZE, FALSE, (DWORD) pid);
|
HANDLE parent = OpenProcess(SYNCHRONIZE, FALSE, (DWORD) pid);
|
||||||
// May return NULL if the parent process has already gone away.
|
// May return NULL if the parent process has already gone away.
|
||||||
// Otherwise, wait for the parent process to exit before starting the
|
// Otherwise, wait for the parent process to exit before starting the
|
||||||
// update.
|
// update.
|
||||||
if (parent) {
|
if (parent) {
|
||||||
DWORD result = WaitForSingleObject(parent, 5000);
|
DWORD result = WaitForSingleObject(parent, 5000);
|
||||||
CloseHandle(parent);
|
CloseHandle(parent);
|
||||||
if (result != WAIT_OBJECT_0)
|
if (result != WAIT_OBJECT_0)
|
||||||
return 1;
|
return 1;
|
||||||
// The process may be signaled before it releases the executable image.
|
// The process may be signaled before it releases the executable image.
|
||||||
// This is a terrible hack, but it'll have to do for now :-(
|
// This is a terrible hack, but it'll have to do for now :-(
|
||||||
Sleep(50);
|
Sleep(50);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
int status;
|
int status;
|
||||||
waitpid(pid, &status, 0);
|
waitpid(pid, &status, 0);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef XP_WIN
|
#ifdef XP_WIN
|
||||||
|
Loading…
x
Reference in New Issue
Block a user