rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
* Re: writeall() is still broken
@ 1991-07-08 16:38 Paul Haahr
  1991-07-09 10:05 ` Boyd Roberts
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Haahr @ 1991-07-08 16:38 UTC (permalink / raw)
  To: John Mackin; +Cc: rc

> After all, if write() to either fd 1 or fd 2 failed, the story truly is
> over, and we're just asking for trouble trying to continue.

i don't think i believe this.  in fact, i think write() calls to 1 and 2  
should not be checked.  what if rc is running w/o being connected to any  
fds, in some sort of daemon or boot environment?  in fact, fd 1 is used  
for so little by rc that it makes even less sense to me that it be  
checked, because places where it is/should be used are all non-essential  
to the core operation of rc.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: writeall() is still broken
  1991-07-08 16:38 writeall() is still broken Paul Haahr
@ 1991-07-09 10:05 ` Boyd Roberts
  0 siblings, 0 replies; 4+ messages in thread
From: Boyd Roberts @ 1991-07-09 10:05 UTC (permalink / raw)
  To: Paul Haahr; +Cc: rc

well, i could believe that my fix would break.  fixing writeall() requires
some degree of thought and knowledge of rc.  you have to know _exactly_ what
is happening when the writall is called.  it's a question of state.  perhaps
rc would be cleaner with two i/o systems?  i'm not sure.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: writeall() is still broken
  1991-07-02  5:31 David Hogan
@ 1991-07-07 15:19 ` John Mackin
  0 siblings, 0 replies; 4+ messages in thread
From: John Mackin @ 1991-07-07 15:19 UTC (permalink / raw)
  To: The rc Mailing List

David Hogan writes:

    The new improved version of writeall() calls uerror() if the write
    fails.  Now uerror() calls fprint(), and fprint() calls writeall().
    Ooops!!

Indeed.  Unfortunately, neither his proposed solution, nor the one that
Boyd mailed to Byron some time ago, is correct in my view.  It's all
very well to take different action depending on which file descriptor
the write failed on -- indeed, I think that is essential -- but the
action that gets taken isn't right.  Compare input.c.  This does the
right thing: if read() fails (except for EINTR, which is very reasonable
to retry), rc exits.  That's correct.  I am not sure what fd's other than
1 or 2 writeall() will ever be called on, under what conditions: if those
are the only ones, then no checking is needed, and a failed write() should
simply cause rc to exit.  If it is called on other fd's, then it is
reasonable to only exit if write() failed on fd 1 or 2.

After all, if write() to either fd 1 or fd 2 failed, the story truly is
over, and we're just asking for trouble trying to continue.

OK,
John.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* writeall() is still broken
@ 1991-07-02  5:31 David Hogan
  1991-07-07 15:19 ` John Mackin
  0 siblings, 1 reply; 4+ messages in thread
From: David Hogan @ 1991-07-02  5:31 UTC (permalink / raw)
  To: The Rc Mailing List

The new improved version of writeall() calls uerror() if the write
fails.  Now uerror() calls fprint(), and fprint() calls writeall().
Ooops!!  What if writes to fd 2 are failing -- can you say
`infinite recursion'?  This typically happens to me when I quit an xterm.

To prevent the crashing and dumping of 67 Meg cores, I have added a test
for whether we are writing to fd 2 or not to writeall(), viz:

void writeall(int fd, char *buf, SIZE_T remain) {
	int i;

	for (i = 0; remain > 0; buf += i, remain -= i)
		if ((i = write(fd, buf, remain)) < 0) {
			if (fd != 2)
				uerror("write");
			rc_error(NULL);
		}
}


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1991-07-09 10:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1991-07-08 16:38 writeall() is still broken Paul Haahr
1991-07-09 10:05 ` Boyd Roberts
  -- strict thread matches above, loose matches on Subject: below --
1991-07-02  5:31 David Hogan
1991-07-07 15:19 ` John Mackin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).