🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #40573

Re: Diablo debugging problems...

#40573
From: Stephen R. van den Berg
Date: Wed, 06 Oct 1999 00:00
31 lines
1812 bytes
Joe Greco <jgreco@ns.sol.net> wrote:
>I'm curious why you're even trying to do this.  Most of Diablo is going to
>be writing to disk (which won't need xwrite) or is using Matt's buffered
>I/O library (which'll probably break if you use xwrite), and the only thing

Basically, check the returnvalue of write() everytime, even for disk I/O,
for two reasons:
- Depending on the underlying disk subsystem, it might return with less than
  what you requested to be written.
- If a signal (any signal) arrives, the write will return early, and will
  need to be restarted.

This is what I usually use as a "reliable"-write():

int rwrite(const int fd,char*a,const unsigned len)
{ int i;size_t left=len;
  do
     while(0>(i=write(fd,a,left))&&errno==EINTR);
  while(i>0&&(a+=i,left-=i));
  return len-left;
}

Add whitespace to taste.
It's less filling and POSIXly correct.
-- 
Sincerely,                                                          srb@cuci.nl
           Stephen R. van den Berg (AKA BuGless).

A truly wise man never plays leapfrog with a unicorn.

Technical Details
Message-ID: <7tebo8$hta$1@zeus.fw.cuci.nl>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
References: <brad-0110991517500001@brad.techos.skynet.be> <brad-0510991348210001@brad.techos.skynet.be> <brad-0510991730300001@brad.techos.skynet.be> <37fa44dc$0$7740@news.execpc.com>

Show Full Headers
Complete Article Headers
Message-ID: <7tebo8$hta$1@zeus.fw.cuci.nl>
Subject: Re: Diablo debugging problems...
Date: Wed, 06 Oct 1999 00:00:00 +0000
From: srb@cuci.nl (Stephen R. van den Berg)
References: <brad-0110991517500001@brad.techos.skynet.be> <brad-0510991348210001@brad.techos.skynet.be> <brad-0510991730300001@brad.techos.skynet.be> <37fa44dc$0$7740@news.execpc.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
X-Deja-AN: 533322596
X-Trace: newspost.cuci.nl 939176524 1892 10.0.0.3
Organization: Cubic Circle
Newsgroups: news.software.nntp