Today I started some mass scanning of pictures (of my wedding) using
SANE. After about 2 dozen I started having scanning problems, and I
couldn't run simple commands like "man"...
After a little investigation it turns out that the mustek, qcam, and
umax backends don't have a SIGCHLD handler and don't do a wait() on
the reader process all the time, so the child processes created by the
backend each time a scan or preview is done stick around until
(x)scanimage exits... The only time a wait() is done by the backends
is if you cancel a scan...
So.... here's a quick patch that fixes the problems in 0.67 (I haven't
grabbed 0.68 quite yet...):
--- mustek.c.orig Thu Dec 4 17:09:52 1997
+++ mustek.c Thu Dec 4 17:15:22 1997
@@ -2614,7 +2614,14 @@
Mustek_Scanner *s = handle;
if (s->reader_pid > 0)
+ {
+ int exit_status;
+
kill (s->reader_pid, SIGTERM);
+ while (wait (&exit_status) != s->reader_pid);
+ s->reader_pid = 0;
+ };
+
s->scanning = SANE_FALSE;
}
--- qcam.c.orig Thu Dec 4 17:09:59 1997
+++ qcam.c Thu Dec 4 17:14:26 1997
@@ -1505,7 +1505,14 @@
sane_cancel (handle);
if (s->reader_pid >= 0)
+ {
+ int exit_status;
+
kill (s->reader_pid, SIGTERM);
+ while (wait (&exit_status) != s->reader_pid);
+ s->reader_pid = 0;
+ };
+
if (s->to_child >= 0)
close (s->to_child);
if (s->from_child >= 0)
@@ -2001,6 +2008,7 @@
char buf[1024];
ssize_t nread;
int flags;
+ int exit_status;
DBG(1, "cancel: cancelling read request\n");
@@ -2026,6 +2034,9 @@
/* now restore non-blocking i/o flag: */
fcntl (s->from_child, F_SETFL, flags & O_NONBLOCK);
+
+ while (wait (&exit_status) != s->reader_pid);
+ s->reader_pid = 0;
DBG(1, "cancel: cancellation completed\n");
}
--- umax.c.orig Thu Dec 4 17:10:07 1997
+++ umax.c Thu Dec 4 17:11:44 1997
@@ -2211,7 +2211,15 @@
DBG(10,"sane_cancel\n");
- if (scanner->reader_pid > 0) { kill(scanner->reader_pid, SIGTERM); }
+ if (scanner->reader_pid > 0)
+ {
+ int exit_status;
+
+ /* ensure child knows it's time to stop: */
+ kill (scanner->reader_pid, SIGTERM);
+ while (wait (&exit_status) != scanner->reader_pid);
+ scanner->reader_pid = 0;
+ }
scanner->scanning = SANE_FALSE;
}
-- ________________________________________________________________________ Mike Sweet Software for SGI and Sun Easy Software Products (301) 373-9603 Workstations 44145 Airport View Drive mike@easysw.com http://www.easysw.com Hollywood, Maryland 20636SUPPORT THE ANTI-SPAM AMENDMENT! - http://www.cauce.org
-- Source code, list archive, and docs: http://www.mostang.com/sane/ To unsubscribe: echo unsubscribe sane-devel | mail majordomo@mostang.com