x11: Minor cleanups and corrections in X11_ShowMessageBox.

Reference issue #3254.
This commit is contained in:
Ryan C. Gordon 2022-03-24 14:25:00 -04:00
parent 6c56193a2a
commit d597a9b431
No known key found for this signature in database
GPG key ID: FA148B892AB48044

View file

@ -830,10 +830,11 @@ X11_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
int exitcode = 0; int exitcode = 0;
close(fds[0]); close(fds[0]);
status = X11_ShowMessageBoxImpl(messageboxdata, buttonid); status = X11_ShowMessageBoxImpl(messageboxdata, buttonid);
if (write(fds[1], &status, sizeof (int)) != sizeof (int)) if (write(fds[1], &status, sizeof (int)) != sizeof (int)) {
exitcode = 1; exitcode = 1;
else if (write(fds[1], buttonid, sizeof (int)) != sizeof (int)) } else if (write(fds[1], buttonid, sizeof (int)) != sizeof (int)) {
exitcode = 1; exitcode = 1;
}
close(fds[1]); close(fds[1]);
_exit(exitcode); /* don't run atexit() stuff, static destructors, etc. */ _exit(exitcode); /* don't run atexit() stuff, static destructors, etc. */
} else { /* we're the parent */ } else { /* we're the parent */
@ -846,13 +847,12 @@ X11_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
SDL_assert(rc == pid); /* not sure what to do if this fails. */ SDL_assert(rc == pid); /* not sure what to do if this fails. */
if ((rc == -1) || (!WIFEXITED(status)) || (WEXITSTATUS(status) != 0)) { if ((rc == -1) || (!WIFEXITED(status)) || (WEXITSTATUS(status) != 0)) {
return SDL_SetError("msgbox child process failed"); status = SDL_SetError("msgbox child process failed");
} else if ( (read(fds[0], &status, sizeof (int)) != sizeof (int)) ||
(read(fds[0], buttonid, sizeof (int)) != sizeof (int)) ) {
status = SDL_SetError("read from msgbox child process failed");
*buttonid = 0;
} }
if (read(fds[0], &status, sizeof (int)) != sizeof (int))
status = -1;
else if (read(fds[0], buttonid, sizeof (int)) != sizeof (int))
status = -1;
close(fds[0]); close(fds[0]);
return status; return status;