Not sure if i should post this on this list or if there is a special someone
that should be aimed by this mail...
My problem was that movemail didn't feed all the mail from my spool file (a
regular file) to my primary inbox : it just stops after about 1kbytes.
Since no one wanted to help me (;-p), i've dig into that code, and found a nice
piece of code that just basically say :
nread=read (fildes,buf,sizeof(buf));
if (nread < sizeof(buf))
break;
So if the system can't completely feed the buffer for some reasons (interrupted
call or whatever), movemail stops and trashes all the mails left in the spool
file...
May be that doesn't happen really often on Unix system (it may really not
happen often, since no one ever reported) but it seems to happen every time on
cygwin (20.1) since only 1000 bytes are feed whereas there is rooms for 1024...
I think no one met this problem on Cygwin 'cuz they either don't use mail or
don't use regular spool file (retrieve directly from pop - remember this wacky
system don't handle mail :-p -...)
I've supposed that 0 byte reads means the end of the file... I'm not satisfied
at all with this, so if someone know how to be sure to have reached the end of
a file using the read method, i'd be glad to hear about it...
Replace the following block (line 432 to line 448) :
{
char buf[1024];
while (1)
{
nread = read (indesc, buf, sizeof buf);
if (nread != write (outdesc, buf, nread))
{
int saved_errno = errno;
unlink (outname);
errno = saved_errno;
pfatal_with_name (outname);
}
if (nread < sizeof buf)
break;
}
}
with the follwing code :
{
char buf[1024];
int tot_written;
int cur_written;
while (1)
{
nread = read (indesc, buf, sizeof buf);
if (nread == 0) /* we assume that 0 byte read means EOF */
break;
if (nread < 0) { /* something went wrong when reading */
int saved_errno = errno;
unlink (outname);
errno = saved_errno;
pfatal_with_name (outname);
}
/* now go for safe and full writing */
tot_written=0;
while (tot_written < nread) {
cur_written=write(outdesc, &(buf[tot_written]),
nread-tot_written);
if (cur_written < 0) { /* something went wrong
while writing */
int saved_errno = errno;
unlink (outname);
errno = saved_errno;
pfatal_with_name (outname);
}
/* Should i do something if nothing is written in a
turn (cur_xxx ==0)...? I'm not sure, but since man
doesn't tell much about this case, i suppose -1 is
the only error case... */
tot_written+=cur_written;
}
}