merge r3992 (restart-helper fixes)

Originally committed to SVN as r4020.
This commit is contained in:
Amar Takhar 2010-01-21 00:26:45 +00:00
parent 4221919d4f
commit 89e2428dbe
2 changed files with 15 additions and 5 deletions

View file

@ -497,7 +497,9 @@ void RestartAegisub() {
char *bundle_path = OSX_GetBundlePath(); char *bundle_path = OSX_GetBundlePath();
char *support_path = OSX_GetBundleSupportFilesDirectory(); char *support_path = OSX_GetBundleSupportFilesDirectory();
if (!bundle_path || !support_path) return; // oops if (!bundle_path || !support_path) return; // oops
wxExecute(wxString::Format(_T("%s/MacOS/restart-helper /usr/bin/open \"%s\""), wxString(support_path, wxConvUTF8).c_str(), wxString(bundle_path, wxConvUTF8).c_str())); wxString exec = wxString::Format(_T("\"%s/MacOS/restart-helper\" /usr/bin/open -n \"%s\"'"), wxString(support_path, wxConvUTF8).c_str(), wxString(bundle_path, wxConvUTF8).c_str());
wxLogDebug("RestartAegisub: (%s)", exec);
wxExecute(exec);
free(bundle_path); free(bundle_path);
free(support_path); free(support_path);
#else #else

View file

@ -52,7 +52,7 @@ int main(int argc, char *argv[], char *env[])
if ((queue = kqueue()) == -1) if ((queue = kqueue()) == -1)
{ {
perror("kqueue()"); perror("Error in: kqueue()");
return 1; return 1;
} }
@ -63,26 +63,34 @@ int main(int argc, char *argv[], char *env[])
NOTE_EXIT, NOTE_EXIT,
0, 0); 0, 0);
printf("restart-helper: waiting for pid %d\n", waitpid);
nchange = kevent(queue, change, 1, event, 1, &timeout); nchange = kevent(queue, change, 1, event, 1, &timeout);
if (nchange < 0) if (nchange < 0)
{ {
perror("kevent()"); perror("restart-helper: Error in kevent()");
return 2; return 2;
} }
else if (nchange == 0) else if (nchange == 0)
{ {
printf("restart-helper: Timed out waiting for pid %d\n", waitpid);
return 3; return 3;
} }
else if (change[0].flags & EV_ERROR) else if (change[0].flags & EV_ERROR)
{ {
perror("restart-helper: Error in event");
return 2; return 2;
} }
else else
{ {
close(queue); close(queue);
printf("restart-helper: Executing '%s'\n", argv[1]);
if (execve(argv[1], argv+1, env) == -1) if (execve(argv[1], argv+1, env) == -1)
{ {
perror("execve()"); perror("restart-helper: Error in execve()");
return 4; return 4;
} }
return 0; /* never reached */ return 0; /* never reached */