User: vins
Date: 05/02/12 03:56:54
Modified: xemacs/src Tag: release-21-4 ChangeLog process-unix.c
Log:
Make sure the last chunk of data gets written to another process.
Revision Changes Path
No revision
No revision
1.290.2.94 +5 -0 XEmacs/xemacs/src/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/ChangeLog,v
retrieving revision 1.290.2.93
retrieving revision 1.290.2.94
diff -u -r1.290.2.93 -r1.290.2.94
--- ChangeLog 2005/02/06 19:23:46 1.290.2.93
+++ ChangeLog 2005/02/12 02:56:47 1.290.2.94
@@ -1,3 +1,8 @@
+2005-02-03 David Evers <extsw(a)appliedgenerics.com>
+
+ * process-unix.c (unix_send_process): Flush the last chunk, even
+ when the pipe is blocked.
+
2005-02-06 Vin Shelton <acs(a)xemacs.org>
* XEmacs 21.4.17 is released
1.20.2.9 +28 -14 XEmacs/xemacs/src/process-unix.c
Index: process-unix.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/process-unix.c,v
retrieving revision 1.20.2.8
retrieving revision 1.20.2.9
diff -u -r1.20.2.8 -r1.20.2.9
--- process-unix.c 2005/01/31 02:55:26 1.20.2.8
+++ process-unix.c 2005/02/12 02:56:50 1.20.2.9
@@ -1293,26 +1293,38 @@
Bufbyte chunkbuf[512];
Bytecount chunklen;
- while (1)
+ do
{
Lstream_data_count writeret;
chunklen = Lstream_read (lstream, chunkbuf, 512);
- if (chunklen <= 0)
- break; /* perhaps should ABORT() if < 0?
- This should never happen. */
old_sigpipe =
(SIGTYPE (*) (int)) signal (SIGPIPE, send_process_trap);
- /* Lstream_write() will never successfully write less than
- the amount sent in. In the worst case, it just buffers
- the unwritten data. */
- writeret = Lstream_write (XLSTREAM (DATA_OUTSTREAM(p)), chunkbuf,
- chunklen);
- signal (SIGPIPE, old_sigpipe);
- if (writeret < 0)
- /* This is a real error. Blocking errors are handled
- specially inside of the filedesc stream. */
- report_file_error ("writing to process", list1 (proc));
+ if (chunklen > 0)
+ {
+ int save_errno;
+
+ /* Lstream_write() will never successfully write less than
+ the amount sent in. In the worst case, it just buffers
+ the unwritten data. */
+ writeret = Lstream_write (XLSTREAM (DATA_OUTSTREAM(p)), chunkbuf,
+ chunklen);
+ save_errno = errno;
+ signal (SIGPIPE, old_sigpipe);
+ errno = save_errno;
+ if (writeret < 0)
+ /* This is a real error. Blocking errors are handled
+ specially inside of the filedesc stream. */
+ report_file_error ("writing to process", list1 (proc));
+ }
+ else
+ {
+ /* Need to make sure that everything up to and including the
+ last chunk is flushed, even when the pipe is currently
+ blocked. */
+ Lstream_flush (XLSTREAM (DATA_OUTSTREAM(p)));
+ signal (SIGPIPE, old_sigpipe);
+ }
while (Lstream_was_blocked_p (XLSTREAM (p->pipe_outstream)))
{
/* Buffer is full. Wait, accepting input;
@@ -1327,7 +1339,9 @@
Lstream_flush (XLSTREAM (p->pipe_outstream));
signal (SIGPIPE, old_sigpipe);
}
+ /* Perhaps should abort() if < 0? This should never happen. */
}
+ while (chunklen > 0);
}
else
{ /* We got here from a longjmp() from the SIGPIPE handler */