Ken Thomases : winspool: Wait for and reap print spool child process.
Alexandre Julliard
julliard at winehq.org
Thu Dec 1 14:05:32 CST 2011
Module: wine
Branch: master
Commit: 6df7adfff1a344ab7983b49e4ccb8f1d133b9171
URL: http://source.winehq.org/git/wine.git/?a=commit;h=6df7adfff1a344ab7983b49e4ccb8f1d133b9171
Author: Ken Thomases <ken at codeweavers.com>
Date: Wed Nov 30 16:49:14 2011 -0600
winspool: Wait for and reap print spool child process.
---
dlls/winspool.drv/info.c | 33 ++++++++++++++++++++++++++++++++-
1 files changed, 32 insertions(+), 1 deletions(-)
diff --git a/dlls/winspool.drv/info.c b/dlls/winspool.drv/info.c
index 7bf9149..68ab5d7 100644
--- a/dlls/winspool.drv/info.c
+++ b/dlls/winspool.drv/info.c
@@ -33,6 +33,12 @@
#include <string.h>
#include <ctype.h>
#include <stddef.h>
+#ifdef HAVE_SYS_ERRNO_H
+#include <sys/errno.h>
+#endif
+#ifdef HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
@@ -7408,6 +7414,8 @@ static BOOL schedule_pipe(LPCWSTR cmd, LPCWSTR filename)
int fds[2] = {-1, -1}, file_fd = -1, no_read;
BOOL ret = FALSE;
char buf[1024];
+ pid_t pid, wret;
+ int status;
if(!(unixname = wine_get_unix_file_name(filename)))
return FALSE;
@@ -7427,7 +7435,7 @@ static BOOL schedule_pipe(LPCWSTR cmd, LPCWSTR filename)
goto end;
}
- if (fork() == 0)
+ if ((pid = fork()) == 0)
{
close(0);
dup2(fds[0], 0);
@@ -7439,10 +7447,33 @@ static BOOL schedule_pipe(LPCWSTR cmd, LPCWSTR filename)
execl("/bin/sh", "/bin/sh", "-c", cmdA, NULL);
_exit(1);
}
+ else if (pid == -1)
+ {
+ ERR("fork() failed!\n");
+ goto end;
+ }
while((no_read = read(file_fd, buf, sizeof(buf))) > 0)
write(fds[1], buf, no_read);
+ close(fds[1]);
+ fds[1] = -1;
+
+ /* reap child */
+ do {
+ wret = waitpid(pid, &status, 0);
+ } while (wret < 0 && errno == EINTR);
+ if (wret < 0)
+ {
+ ERR("waitpid() failed!\n");
+ goto end;
+ }
+ if (!WIFEXITED(status) || WEXITSTATUS(status))
+ {
+ ERR("child process failed! %d\n", status);
+ goto end;
+ }
+
ret = TRUE;
end:
More information about the wine-cvs
mailing list