Mercurial > hg > xemacs-beta
comparison src/process-unix.c @ 2566:045f20e1c3af
[xemacs-hg @ 2005-02-04 04:06:23 by james]
Thanks to David Evers, the dreaded email truncation bug should now be gone.
See the xemacs-patches message with ID <ps3bwdnf8i.fsf@diannao.ittc.ku.edu>.
author | james |
---|---|
date | Fri, 04 Feb 2005 04:06:34 +0000 |
parents | 3d8143fc88e1 |
children | 4c41ea11201a |
comparison
equal
deleted
inserted
replaced
2565:744de5f3f284 | 2566:045f20e1c3af |
---|---|
1509 stream buffer) so as to avoid inundating the stream with blocked | 1509 stream buffer) so as to avoid inundating the stream with blocked |
1510 data. */ | 1510 data. */ |
1511 Ibyte chunkbuf[512]; | 1511 Ibyte chunkbuf[512]; |
1512 Bytecount chunklen; | 1512 Bytecount chunklen; |
1513 | 1513 |
1514 while (1) | 1514 do |
1515 { | 1515 { |
1516 int writeret; | 1516 int writeret; |
1517 | 1517 |
1518 chunklen = Lstream_read (lstream, chunkbuf, 512); | 1518 chunklen = Lstream_read (lstream, chunkbuf, 512); |
1519 if (chunklen <= 0) | |
1520 break; /* perhaps should ABORT() if < 0? | |
1521 This should never happen. */ | |
1522 old_sigpipe = | 1519 old_sigpipe = |
1523 (SIGTYPE (*) (int)) EMACS_SIGNAL (SIGPIPE, send_process_trap); | 1520 (SIGTYPE (*) (int)) EMACS_SIGNAL (SIGPIPE, send_process_trap); |
1524 /* Lstream_write() will never successfully write less than | 1521 if (chunklen > 0) |
1525 the amount sent in. In the worst case, it just buffers | 1522 { |
1526 the unwritten data. */ | 1523 int save_errno; |
1527 writeret = Lstream_write (XLSTREAM (DATA_OUTSTREAM (p)), chunkbuf, | 1524 |
1528 chunklen); | 1525 /* Lstream_write() will never successfully write less than |
1529 { | 1526 the amount sent in. In the worst case, it just buffers |
1530 int save_errno = errno; | 1527 the unwritten data. */ |
1531 EMACS_SIGNAL (SIGPIPE, old_sigpipe); | 1528 writeret = Lstream_write (XLSTREAM (DATA_OUTSTREAM(p)), chunkbuf, |
1532 errno = save_errno; | 1529 chunklen); |
1533 if (writeret < 0) | 1530 save_errno = errno; |
1534 /* This is a real error. Blocking errors are handled | 1531 EMACS_SIGNAL (SIGPIPE, old_sigpipe); |
1535 specially inside of the filedesc stream. */ | 1532 errno = save_errno; |
1536 report_process_error ("writing to process", proc); | 1533 if (writeret < 0) |
1537 } | 1534 /* This is a real error. Blocking errors are handled |
1535 specially inside of the filedesc stream. */ | |
1536 report_file_error ("writing to process", list1 (proc)); | |
1537 } | |
1538 else | |
1539 { | |
1540 /* Need to make sure that everything up to and including the | |
1541 last chunk is flushed, even when the pipe is currently | |
1542 blocked. */ | |
1543 Lstream_flush (XLSTREAM (DATA_OUTSTREAM(p))); | |
1544 EMACS_SIGNAL (SIGPIPE, old_sigpipe); | |
1545 } | |
1538 while (Lstream_was_blocked_p (XLSTREAM (p->pipe_outstream))) | 1546 while (Lstream_was_blocked_p (XLSTREAM (p->pipe_outstream))) |
1539 { | 1547 { |
1540 /* Buffer is full. Wait, accepting input; | 1548 /* Buffer is full. Wait, accepting input; |
1541 that may allow the program | 1549 that may allow the program |
1542 to finish doing output and read more. */ | 1550 to finish doing output and read more. */ |
1547 old_sigpipe = | 1555 old_sigpipe = |
1548 (SIGTYPE (*) (int)) EMACS_SIGNAL (SIGPIPE, send_process_trap); | 1556 (SIGTYPE (*) (int)) EMACS_SIGNAL (SIGPIPE, send_process_trap); |
1549 Lstream_flush (XLSTREAM (p->pipe_outstream)); | 1557 Lstream_flush (XLSTREAM (p->pipe_outstream)); |
1550 EMACS_SIGNAL (SIGPIPE, old_sigpipe); | 1558 EMACS_SIGNAL (SIGPIPE, old_sigpipe); |
1551 } | 1559 } |
1560 /* Perhaps should ABORT() if < 0? This should never happen. */ | |
1552 } | 1561 } |
1562 while (chunklen > 0); | |
1553 } | 1563 } |
1554 else | 1564 else |
1555 { /* We got here from a longjmp() from the SIGPIPE handler */ | 1565 { /* We got here from a longjmp() from the SIGPIPE handler */ |
1556 EMACS_SIGNAL (SIGPIPE, old_sigpipe); | 1566 EMACS_SIGNAL (SIGPIPE, old_sigpipe); |
1557 /* Close the file lstream so we don't attempt to write to it further */ | 1567 /* Close the file lstream so we don't attempt to write to it further */ |