Re: [AD] xmessage broken pipe |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
- To: alleg-developers@xxxxxxxxxx
- Subject: Re: [AD] xmessage broken pipe
- From: Chris <chris.kcat@xxxxxxxxxx>
- Date: Fri, 10 Dec 2004 06:14:42 -0800
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:return-path:message-id:date:from:user-agent:x-accept-language:mime-version:to:subject:references:in-reply-to:x-enigmail-version:x-enigmail-supports:content-type; b=bTigwQOE4F9QN23kpRdVhJw8ck875XoTMwbjAue1HMcKvXmy3SgMHFtW+wnsKI9hieVgRl85XLrpg2wf8FBzCHthtWhsV/qxbY3J4tzdWEAmBCpsdWW71TnBN8Dt2lMdF8sW0gpWA+rPk6M8ssXpJRkkta1bxBmTd3Wbu8HE2AE=
Updated patch. Now it doesn't use pipes at all, instead opting to pass
the message directly via argv.
Index: src/x/xsystem.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/x/xsystem.c,v
retrieving revision 1.31
diff -u -r1.31 xsystem.c
--- src/x/xsystem.c 29 Nov 2004 08:09:06 -0000 1.31
+++ src/x/xsystem.c 10 Dec 2004 14:15:02 -0000
@@ -207,7 +207,7 @@
get_executable_name(tmp, sizeof(tmp));
set_window_title(get_filename(tmp));
- /* Open the display, create a window, and background-process
+ /* Open the display, create a window, and background-process
* events for it all. */
if (_xwin_open_display(0) || _xwin_create_window()
|| _unix_bg_man->register_func (_xwin_bg_handler)) {
@@ -280,7 +280,6 @@
static int _xwin_sysdrv_set_close_button_callback(void (*proc)(void))
{
_xwin.close_button_callback = proc;
-
return 0;
}
@@ -293,51 +292,35 @@
{
char buf[ALLEGRO_MESSAGE_SIZE];
char *msg2;
- int fd[2];
pid_t pid;
- int ret, status;
- int err;
+ int status;
/* convert message to ASCII */
msg2 = uconvert(msg, U_CURRENT, buf, U_ASCII, ALLEGRO_MESSAGE_SIZE);
- /* create a pipe */
- if (pipe(fd) != 0) {
- fputs(msg2, stdout);
- return;
- }
-
/* fork a child */
pid = fork();
switch (pid) {
case -1: /* fork error */
- close(fd[0]);
- close(fd[1]);
fputs(msg2, stdout);
break;
case 0: /* child process */
- if ((close(STDIN_FILENO) != -1)
- && (dup2(fd[0], STDIN_FILENO) != -1)
- && (close(fd[1]) != -1))
- {
- execlp("xmessage", "xmessage", "-buttons", "OK", "-default", "OK", "-center", "-file", "-", NULL);
- }
+ execlp("xmessage", "xmessage", "-buttons", "OK:101", "-default", "OK", "-center", msg2, NULL);
+
/* if execution reaches here, it means execlp failed */
_exit(EXIT_FAILURE);
break;
default: /* parent process */
- if ((close(fd[0]) == -1)
- || (write(fd[1], msg2, strlen(msg2)) == -1)
- || (close(fd[1]) == -1)
- || (waitpid(pid, &status, 0) != pid)
- || (!WIFEXITED(status))
+ waitpid(pid, &status, 0);
+ if ((!WIFEXITED(status))
|| (WEXITSTATUS(status) != 101)) /* ok button */
{
fputs(msg2, stdout);
}
+
break;
}
}