Report forwarded to debian-devel@lists.debian.org, Chris Fearnley <cjf@netaxs.com>:
Bug#4293; Package mawk.
debian-devel@lists.debian.orgChris Fearnley
Subject: Bug#4293: mawk doesn't report an error on full filesystems
Reply-To: Herbert Thielen , 4293@bugs.debian.org
Resent-From: Herbert Thielen
Resent-To: debian-devel@lists.debian.org
Resent-CC: Chris Fearnley
Resent-Date: Mon, 26 Aug 1996 15:18:01 GMT
Resent-Message-ID:
Resent-Sender: iwj@debian.org
X-Debian-PR-Package: mawk
X-Debian-PR-Keywords:
X-Loop: owner@bugs.debian.org
Received: via spool by bugs@bugs.debian.org id=B.84107245217173
(code B ref -1); Mon, 26 Aug 1996 15:18:01 GMT
From: Herbert Thielen
Message-Id: <199608261243.OAA02314@ion.lpr.e-technik.tu-muenchen.de>
To: submit@bugs.debian.org
Date: Mon, 26 Aug 1996 14:43:47 +0200 (MET DST)
Cc: herbert.thielen@lpr.e-technik.tu-muenchen.de
X-Mailer: ELM [version 2.4 PL24 ME7a]
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Package: mawk
Version: 1.2.2-1
Mawk doesn't report an error when writing to a full filesystem:
$ mawk '{print}' < /etc/motd > /dev/full
$ echo $?
0
Probably no write error is catched. Gawk does it's job correct:
$ gawk '{print}' < /etc/motd > /dev/full
gawk: cmd. line:1: (FILENAME=- FNR=9) warning: error writing standard output (No space left on device)
Regards
Herbert.
Acknowledgement sent to Herbert Thielen <Herbert.Thielen@lpr.e-technik.tu-muenchen.de>:
New bug report received and forwarded. Copy sent to Chris Fearnley <cjf@netaxs.com>.
-t
From: owner@bugs.debian.org (Ian Jackson)
To: Herbert Thielen
Subject: Bug#4293: Acknowledgement (was: mawk doesn't report an error on full filesystems)
Message-ID:
In-Reply-To: <199608261243.OAA02314@ion.lpr.e-technik.tu-muenchen.de>
References: <199608261243.OAA02314@ion.lpr.e-technik.tu-muenchen.de>
Thank you for the problem report you have sent regarding Debian Linux.
This is an automatically generated reply, to let you know your message has
been received. It is being forwarded to the developers' mailing list for
their attention; they will reply in due course.
Your message has been sent to the package maintainer(s):
Chris Fearnley
If you wish to submit further information on your problem, please send
it to 4293@bugs.debian.org (and *not* to
bugs@bugs.debian.org).
Please do not reply to the address at the top of this message,
unless you wish to report a problem with the bug-tracking system.
Ian Jackson
(maintainer, Debian bug tracking system)
Received: (at submit) by bugs.debian.org; 26 Aug 1996 15:14:12 +0000
Received: (qmail-queue invoked from smtpd); 26 Aug 1996 15:09:01 -0000
Received: from spock.lpr.e-technik.tu-muenchen.de (root@129.187.151.1)
by master.debian.org with SMTP; 26 Aug 1996 15:08:57 -0000
Received: from ion.lpr.e-technik.tu-muenchen.de (ion.lpr.e-technik.tu-muenchen.de [129.187.151.28]) by spock.lpr.e-technik.tu-muenchen.de (8.6.12/8.6.6) with ESMTP id RAA17379; Mon, 26 Aug 1996 17:03:35 +0200
Received: (from thielen@localhost) by ion.lpr.e-technik.tu-muenchen.de (8.7.5/8.7.3) id OAA02314; Mon, 26 Aug 1996 14:43:48 +0200
From: Herbert Thielen
Message-Id: <199608261243.OAA02314@ion.lpr.e-technik.tu-muenchen.de>
Subject: mawk doesn't report an error on full filesystems
To: submit@bugs.debian.org
Date: Mon, 26 Aug 1996 14:43:47 +0200 (MET DST)
Cc: herbert.thielen@lpr.e-technik.tu-muenchen.de
X-Mailer: ELM [version 2.4 PL24 ME7a]
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Package: mawk
Version: 1.2.2-1
Mawk doesn't report an error when writing to a full filesystem:
$ mawk '{print}' < /etc/motd > /dev/full
$ echo $?
0
Probably no write error is catched. Gawk does it's job correct:
$ gawk '{print}' < /etc/motd > /dev/full
gawk: cmd. line:1: (FILENAME=- FNR=9) warning: error writing standard output (No space left on device)
Regards
Herbert.
Information forwarded to Chris Fearnley <cjf@netaxs.com>:
Bug#4293; Package mawk.
Chris Fearnley
Subject: Bug#4293: Old bugs need to be looked at
Reply-To: remco@blaakmeer.student.utwente.nl (Remco Blaakmeer), 4293-maintonly@bugs.debian.org
Resent-From: remco@blaakmeer.student.utwente.nl (Remco Blaakmeer)
Resent-To: Chris Fearnley
Resent-Date: Sun, 01 Feb 1998 11:33:08 GMT
Resent-Message-ID:
Resent-Sender: iwj@debian.org
X-Debian-PR-Message: report 4293
X-Debian-PR-Package: mawk
X-Debian-PR-Keywords:
X-Loop: owner@bugs.debian.org
Received: via spool by 4293-maintonly@bugs.debian.org id=M4293.8863321501684
(code M ref 4293); Sun, 01 Feb 1998 11:33:08 GMT
Message-Id:
Date: Sun, 1 Feb 1998 12:22:25 +0100 (CET)
From: remco@blaakmeer.student.utwente.nl (Remco Blaakmeer)
To: 4293-maintonly@bugs.debian.org
This is an automated message sent to all bugs older than one year.
This bug is very old. Please take a look at it and see if you can fix it.
If it has already been fixed, please close it.
If you have problems fixing it or if you don't have the time to fix it,
please ask the people on debian-devel@lists.debian.org for help, so that
at least the oldest bugs can be solved before Debian 2.0 is released.
Remco Blaakmeer
Acknowledgement sent to remco@blaakmeer.student.utwente.nl (Remco Blaakmeer):
Extra info received and forwarded to maintainer. Copy sent to Chris Fearnley <cjf@netaxs.com>.
-t
From: owner@bugs.debian.org (Ian Jackson)
To: remco@blaakmeer.student.utwente.nl (Remco Blaakmeer)
Subject: Bug#4293: Info received for maintainer only
(was Old bugs need to be looked at)
Message-ID:
In-Reply-To:
References:
X-Debian-PR-Message: ack-info 4293
Thank you for the additional information you have supplied regarding
this problem report. It has been forwarded to the developer(s) (but
not to the mailing list) to accompany the original report.
Your message has been sent to the package maintainer(s):
Chris Fearnley
If you wish to continue to submit further information on your problem,
please send it to 4293-maintonly@bugs.debian.org, as before.
Please do not reply to the address at the top of this message,
unless you wish to report a problem with the bug-tracking system.
Ian Jackson
(administrator, Debian bugs database)
Received: (at 4293-maintonly) by bugs.debian.org; 1 Feb 1998 11:22:30 +0000
Received: (qmail 1681 invoked by uid 71); 1 Feb 1998 11:22:29 -0000
Received: from cal011205.student.utwente.nl (HELO blaakmeer.student.utwente.nl) (root@130.89.222.95)
by debian.novare.net with SMTP; 1 Feb 1998 11:22:29 -0000
Received: by blaakmeer.student.utwente.nl
id m0xyxTl-0013upC
(Debian Smail-3.2.0.100 1997-Dec-8 #2); Sun, 1 Feb 1998 12:22:25 +0100 (CET)
Message-Id:
Date: Sun, 1 Feb 1998 12:22:25 +0100 (CET)
From: remco@blaakmeer.student.utwente.nl (Remco Blaakmeer)
To: 4293-maintonly@bugs.debian.org
Subject: Old bugs need to be looked at
This is an automated message sent to all bugs older than one year.
This bug is very old. Please take a look at it and see if you can fix it.
If it has already been fixed, please close it.
If you have problems fixing it or if you don't have the time to fix it,
please ask the people on debian-devel@lists.debian.org for help, so that
at least the oldest bugs can be solved before Debian 2.0 is released.
Remco Blaakmeer
Merged 4293 28249.
Request was from Torsten Landschoff <t.landschoff@gmx.net>
to control@bugs.debian.org.
Received: (at control) by bugs.debian.org; 30 Mar 1999 00:19:57 +0000
Received: (qmail 2947 invoked from network); 30 Mar 1999 00:19:56 -0000
Received: from authsrv.nacamar.de (HELO dialup.nacamar.de) (194.162.162.197)
by master.debian.org with SMTP; 30 Mar 1999 00:19:56 -0000
Received: (qmail 22788 invoked from network); 30 Mar 1999 00:19:55 -0000
Received: from dialup18-110.access.nacamar.de (HELO wormhole.galaxy) (torsten@62.144.239.110)
by authsrv.nacamar.de with SMTP; 30 Mar 1999 00:19:55 -0000
Received: (from torsten@localhost)
by wormhole.galaxy (8.8.8/8.8.8/Debian/GNU) id CAA03819
for control@bugs.debian.org; Tue, 30 Mar 1999 02:19:20 +0200
Date: Tue, 30 Mar 1999 02:19:20 +0200
From: Torsten Landschoff
To: control@bugs.debian.org
Subject: This bugs are the same...
Message-ID: <19990330021920.A3805@asterix.kupenga.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Mailer: Mutt 0.94.17i
merge 4293 28249
thanks
Information forwarded to debian-bugs-dist@lists.debian.org, James Troup <awkmaint@nocrew.org>:
Bug#4293; Package mawk.
debian-bugs-dist@lists.debian.orgJames Troup
Subject: Bug#4293: [PATCH] The libc is corrent, mawk is wrong
Reply-To: Torsten Landschoff , 4293@bugs.debian.org
Resent-From: Torsten Landschoff
Resent-To: debian-bugs-dist@lists.debian.org
Resent-CC: James Troup
Resent-Date: Tue, 30 Mar 1999 00:48:02 GMT
Resent-Message-ID:
Resent-Sender: iwj@debian.org
X-Debian-PR-Message: report 4293
X-Debian-PR-Package: mawk
X-Debian-PR-Keywords:
X-Loop: owner@bugs.debian.org
Received: via spool by 4293-bugs@bugs.debian.org id=B4293.9227546736803
(code B ref 4293); Tue, 30 Mar 1999 00:48:02 GMT
Date: Tue, 30 Mar 1999 02:44:28 +0200
From: Torsten Landschoff
To: 4293@bugs.debian.org
Cc: Christian Kurz
Message-ID: <19990330024428.A3820@asterix.kupenga.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Mailer: Mutt 0.94.17i
Hi Folks,
"Shorty" alias Christian Kurz pointed me towards this bug. I took the time to
do a small patch to this. I would like to comment on the messages in the BTS
concerning this bug:
Debian bug report logs - #4293
mawk doesn't report an error on full filesystems
[...]
> Mawk doesn't report an error when writing to a full filesystem:
>
> $ mawk '{print}' < /etc/motd > /dev/full
> $ echo $?
> 0
>
> Probably no write error is catched. Gawk does it's job correct:
In fact the return value of fclose is not checked or fflush is not called
respectivly.
Debian bug report logs - #28249
mawk doesn't check write errors
From: Anthony Towns
[...]
> Hello world,
>
> Here's some sample code that demonstrates how to check this correctly
> (afaict):
>
>
> #include
> #define FOO "Foo"
> int main(void) {
> if ( strlen(FOO) + 1 != printf( "%s\n", FOO ) ) {
> perror( "printf" ); /* printf reported the error */
> }
>
> if ( EOF == fflush(stdout) ) {
> perror( "fflush" ); /* the output was buffered, and the
> * error wasn't noticed until it was
> * flushed
> */
> }
>
> exit(0);
> }
Right. Probably it should be done that way. Problem is: I do not know where to
place the call to fflush correctly ;)
> [...]
> So to report errors in every case, programs do need to explicitly check
> *every* printf, *and* explicitly fflush before calling exit, and check
> the return value of that.
This is really needed :( That's what I have learned from this bugs. In the
past I did never check the return value of fclose - I never thought of the
buffering the library might have done...
> From: Chris Fearnley
> [...]
> The problem, as I discussed with the upstream author at the time of #4293,
> is that mawk doesn't flush it's buffers properly before closing them.
> Hence unless the file is greater than 4096 bytes (on Linux - other
> OSs seem to notice the problem on close and hence do not experience
> this problem with mawk - it's just a peculiarity of our libc stdlib
> buffering).
Our libc DOES notice the problem on close - at least since hamm, I do not want
to install bo to check against libc5 ;) But mawk does not check the return
value of fclose.
Some comment on what the patch does:
1. I added a function close_error to files.c to report the problem if
the file can't be closed.
2. I moved the prototypes behind the type declarations because I need
a type declared there and I think the prototypes should be at one place.
3. I checked the return value of every fclose call (I did not do that in
fin.c because it closes only input streams so there should not be such
a problem) and called close_error accordingly.
4. This leads to an infinite loop because mawk_exit calls close_out_pipes
in turn which tries to close the same file again and so on...
So I changed close_out_pipes and file_close to remove the item from the
list before calling close_error. This way both functions can be
reentered but control should not return to the previous invocation - I
did not think about the consequences. I guess it would not work ;)
I hope the patch is okay. Please forward it upstream if you decide to
incorporate it - there is no need to invent the wheel twice ;)
cu
Torsten
=== PATCH FOLLOWS ===
diff -r -u mawk-1.3.3/files.c mawk-1.3.3.new/files.c
--- mawk-1.3.3/files.c Sun Jan 14 18:14:10 1996
+++ mawk-1.3.3.new/files.c Tue Mar 30 00:39:31 1999
@@ -61,17 +61,11 @@
#include "memory.h"
#include "fin.h"
-static FILE *PROTO(tfopen, (char *, char *)) ;
-static void PROTO(efflush, (FILE*)) ;
-static void PROTO(add_to_child_list, (int, int)) ;
-static struct child *PROTO(remove_from_child_list, (int)) ;
-extern int PROTO(isatty, (int)) ;
#ifdef V7
#include /* defines FIOCLEX */
#endif
-
#ifndef NO_FCNTL_H
#include
@@ -103,6 +97,14 @@
static FILE_NODE *file_list ;
+/* Prototypes for local functions */
+
+static FILE *PROTO(tfopen, (char *, char *)) ;
+static void PROTO(efflush, (FILE*)) ;
+static void PROTO(add_to_child_list, (int, int)) ;
+static struct child *PROTO(remove_from_child_list, (int)) ;
+extern int PROTO(isatty, (int)) ;
+static void PROTO(close_error, (FILE_NODE *p));
/* find a file on file_list */
PTR
@@ -233,16 +235,28 @@
if (strcmp(name, p->name->str) == 0)
{
/* found */
- switch (p->type)
+
+ /* Remove it from the list first because we might be called
+ again if an error occurs leading to an infinite loop.
+
+ Note that we don't have to consider the list corruption
+ cause by a recursive call because it will never return. */
+
+ q->link = p->link ;
+ file_list = dummy.link ; /* maybe it was the first file */
+
+ switch (p->type)
{
case F_TRUNC:
case F_APPEND:
- fclose((FILE *) p->ptr) ;
+ if( fclose((FILE *) p->ptr) != 0 )
+ close_error(p) ;
retval = 0 ;
break ;
case PIPE_OUT:
- fclose((FILE *) p->ptr) ;
+ if( fclose((FILE *) p->ptr) != 0 )
+ close_error(p) ;
#if HAVE_REAL_PIPES
retval = wait_for(p->pid) ;
@@ -274,8 +288,8 @@
}
free_STRING(p->name) ;
- hold = p ;
- q->link = p = p->link ;
+ hold = p ;
+ p = p->link ;
ZFREE(hold) ;
}
else
@@ -284,7 +298,6 @@
}
}
- file_list = dummy.link ;
return retval ;
}
@@ -364,7 +377,14 @@
{
if (IS_OUTPUT(p->type))
{
- fclose((FILE *) p->ptr) ;
+ if( fclose((FILE *) p->ptr) != 0 )
+ {
+ /* if another error occurs we do not want to be called
+ for the same file again */
+
+ file_list = p->link ;
+ close_error(p) ;
+ }
if (p->type == PIPE_OUT) wait_for(p->pid) ;
}
@@ -397,7 +417,8 @@
{
if (p->type == PIPE_OUT)
{
- fclose(p->ptr) ;
+ if( fclose(p->ptr) != 0 )
+ close_error(p) ;
close_fake_outpipe(p->name->str, p->pid) ;
}
p = p->link ;
@@ -563,18 +584,24 @@
set_stderr() /* and stdout */
{
FILE_NODE *p, *q ;
+
+ /* We insert stderr first to get it at the end of the list. This is
+ needed because we want to output errors encountered on closing
+ stdout. */
- p = ZMALLOC(FILE_NODE) ;
- p->link = (FILE_NODE*) 0 ;
- p->type = F_TRUNC ;
- p->name = new_STRING("/dev/stdout") ;
- p->ptr = (PTR) stdout ;
q = ZMALLOC(FILE_NODE);
- q->link = p ;
+ q->link = (FILE_NODE*) 0 ;
q->type = F_TRUNC ;
q->name = new_STRING("/dev/stderr") ;
q->ptr = (PTR) stderr ;
- file_list = q ;
+
+ p = ZMALLOC(FILE_NODE) ;
+ p->link = q;
+ p->type = F_TRUNC ;
+ p->name = new_STRING("/dev/stdout") ;
+ p->ptr = (PTR) stdout ;
+
+ file_list = p ;
}
/* fopen() but no buffering to ttys */
@@ -619,3 +646,13 @@
}
}
#endif /* MSDOS */
+
+/* An error occured closing the file referred to by P. We tell the
+ user and terminate the program. */
+
+static void close_error(p)
+ FILE_NODE *p ;
+{
+ errmsg(errno, "close failed on file %s", p->name->str) ;
+ mawk_exit(2) ;
+}
Acknowledgement sent to Torsten Landschoff <t.landschoff@gmx.net>:
Extra info received and forwarded to list. Copy sent to James Troup <awkmaint@nocrew.org>.
-t
From: owner@bugs.debian.org (Debian Bug Tracking System)
To: Torsten Landschoff
Subject: Bug#4293: Info received (was [PATCH] The libc is corrent, mawk is wrong)
Message-ID:
In-Reply-To: <19990330024428.A3820@asterix.kupenga.com>
References: <19990330024428.A3820@asterix.kupenga.com>
X-Debian-PR-Message: ack-info-maintonly 4293
Thank you for the additional information you have supplied regarding
this problem report. It has been forwarded to the developer(s) and
to the developers' mailing list to accompany the original report.
Your message has been sent to the package maintainer(s):
James Troup
If you wish to continue to submit further information on your problem,
please send it to 4293@bugs.debian.org, as before.
Please do not reply to the address at the top of this message,
unless you wish to report a problem with the bug-tracking system.
Ian Jackson
(administrator, Debian bugs database)
Received: (at 4293) by bugs.debian.org; 30 Mar 1999 00:44:33 +0000
Received: (qmail 6800 invoked from network); 30 Mar 1999 00:44:33 -0000
Received: from authsrv.nacamar.de (HELO dialup.nacamar.de) (194.162.162.197)
by master.debian.org with SMTP; 30 Mar 1999 00:44:33 -0000
Received: (qmail 26039 invoked from network); 30 Mar 1999 00:44:19 -0000
Received: from dialup18-110.access.nacamar.de (HELO wormhole.galaxy) (torsten@62.144.239.110)
by authsrv.nacamar.de with SMTP; 30 Mar 1999 00:44:19 -0000
Received: (from torsten@localhost)
by wormhole.galaxy (8.8.8/8.8.8/Debian/GNU) id CAA03852;
Tue, 30 Mar 1999 02:44:28 +0200
Date: Tue, 30 Mar 1999 02:44:28 +0200
From: Torsten Landschoff
To: 4293@bugs.debian.org
Cc: Christian Kurz
Subject: [PATCH] The libc is corrent, mawk is wrong
Message-ID: <19990330024428.A3820@asterix.kupenga.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Mailer: Mutt 0.94.17i
Hi Folks,
"Shorty" alias Christian Kurz pointed me towards this bug. I took the time to
do a small patch to this. I would like to comment on the messages in the BTS
concerning this bug:
Debian bug report logs - #4293
mawk doesn't report an error on full filesystems
[...]
> Mawk doesn't report an error when writing to a full filesystem:
>
> $ mawk '{print}' < /etc/motd > /dev/full
> $ echo $?
> 0
>
> Probably no write error is catched. Gawk does it's job correct:
In fact the return value of fclose is not checked or fflush is not called
respectivly.
Debian bug report logs - #28249
mawk doesn't check write errors
From: Anthony Towns
[...]
> Hello world,
>
> Here's some sample code that demonstrates how to check this correctly
> (afaict):
>
>
> #include
> #define FOO "Foo"
> int main(void) {
> if ( strlen(FOO) + 1 != printf( "%s\n", FOO ) ) {
> perror( "printf" ); /* printf reported the error */
> }
>
> if ( EOF == fflush(stdout) ) {
> perror( "fflush" ); /* the output was buffered, and the
> * error wasn't noticed until it was
> * flushed
> */
> }
>
> exit(0);
> }
Right. Probably it should be done that way. Problem is: I do not know where to
place the call to fflush correctly ;)
> [...]
> So to report errors in every case, programs do need to explicitly check
> *every* printf, *and* explicitly fflush before calling exit, and check
> the return value of that.
This is really needed :( That's what I have learned from this bugs. In the
past I did never check the return value of fclose - I never thought of the
buffering the library might have done...
> From: Chris Fearnley
> [...]
> The problem, as I discussed with the upstream author at the time of #4293,
> is that mawk doesn't flush it's buffers properly before closing them.
> Hence unless the file is greater than 4096 bytes (on Linux - other
> OSs seem to notice the problem on close and hence do not experience
> this problem with mawk - it's just a peculiarity of our libc stdlib
> buffering).
Our libc DOES notice the problem on close - at least since hamm, I do not want
to install bo to check against libc5 ;) But mawk does not check the return
value of fclose.
Some comment on what the patch does:
1. I added a function close_error to files.c to report the problem if
the file can't be closed.
2. I moved the prototypes behind the type declarations because I need
a type declared there and I think the prototypes should be at one place.
3. I checked the return value of every fclose call (I did not do that in
fin.c because it closes only input streams so there should not be such
a problem) and called close_error accordingly.
4. This leads to an infinite loop because mawk_exit calls close_out_pipes
in turn which tries to close the same file again and so on...
So I changed close_out_pipes and file_close to remove the item from the
list before calling close_error. This way both functions can be
reentered but control should not return to the previous invocation - I
did not think about the consequences. I guess it would not work ;)
I hope the patch is okay. Please forward it upstream if you decide to
incorporate it - there is no need to invent the wheel twice ;)
cu
Torsten
=== PATCH FOLLOWS ===
diff -r -u mawk-1.3.3/files.c mawk-1.3.3.new/files.c
--- mawk-1.3.3/files.c Sun Jan 14 18:14:10 1996
+++ mawk-1.3.3.new/files.c Tue Mar 30 00:39:31 1999
@@ -61,17 +61,11 @@
#include "memory.h"
#include "fin.h"
-static FILE *PROTO(tfopen, (char *, char *)) ;
-static void PROTO(efflush, (FILE*)) ;
-static void PROTO(add_to_child_list, (int, int)) ;
-static struct child *PROTO(remove_from_child_list, (int)) ;
-extern int PROTO(isatty, (int)) ;
#ifdef V7
#include /* defines FIOCLEX */
#endif
-
#ifndef NO_FCNTL_H
#include
@@ -103,6 +97,14 @@
static FILE_NODE *file_list ;
+/* Prototypes for local functions */
+
+static FILE *PROTO(tfopen, (char *, char *)) ;
+static void PROTO(efflush, (FILE*)) ;
+static void PROTO(add_to_child_list, (int, int)) ;
+static struct child *PROTO(remove_from_child_list, (int)) ;
+extern int PROTO(isatty, (int)) ;
+static void PROTO(close_error, (FILE_NODE *p));
/* find a file on file_list */
PTR
@@ -233,16 +235,28 @@
if (strcmp(name, p->name->str) == 0)
{
/* found */
- switch (p->type)
+
+ /* Remove it from the list first because we might be called
+ again if an error occurs leading to an infinite loop.
+
+ Note that we don't have to consider the list corruption
+ cause by a recursive call because it will never return. */
+
+ q->link = p->link ;
+ file_list = dummy.link ; /* maybe it was the first file */
+
+ switch (p->type)
{
case F_TRUNC:
case F_APPEND:
- fclose((FILE *) p->ptr) ;
+ if( fclose((FILE *) p->ptr) != 0 )
+ close_error(p) ;
retval = 0 ;
break ;
case PIPE_OUT:
- fclose((FILE *) p->ptr) ;
+ if( fclose((FILE *) p->ptr) != 0 )
+ close_error(p) ;
#if HAVE_REAL_PIPES
retval = wait_for(p->pid) ;
@@ -274,8 +288,8 @@
}
free_STRING(p->name) ;
- hold = p ;
- q->link = p = p->link ;
+ hold = p ;
+ p = p->link ;
ZFREE(hold) ;
}
else
@@ -284,7 +298,6 @@
}
}
- file_list = dummy.link ;
return retval ;
}
@@ -364,7 +377,14 @@
{
if (IS_OUTPUT(p->type))
{
- fclose((FILE *) p->ptr) ;
+ if( fclose((FILE *) p->ptr) != 0 )
+ {
+ /* if another error occurs we do not want to be called
+ for the same file again */
+
+ file_list = p->link ;
+ close_error(p) ;
+ }
if (p->type == PIPE_OUT) wait_for(p->pid) ;
}
@@ -397,7 +417,8 @@
{
if (p->type == PIPE_OUT)
{
- fclose(p->ptr) ;
+ if( fclose(p->ptr) != 0 )
+ close_error(p) ;
close_fake_outpipe(p->name->str, p->pid) ;
}
p = p->link ;
@@ -563,18 +584,24 @@
set_stderr() /* and stdout */
{
FILE_NODE *p, *q ;
+
+ /* We insert stderr first to get it at the end of the list. This is
+ needed because we want to output errors encountered on closing
+ stdout. */
- p = ZMALLOC(FILE_NODE) ;
- p->link = (FILE_NODE*) 0 ;
- p->type = F_TRUNC ;
- p->name = new_STRING("/dev/stdout") ;
- p->ptr = (PTR) stdout ;
q = ZMALLOC(FILE_NODE);
- q->link = p ;
+ q->link = (FILE_NODE*) 0 ;
q->type = F_TRUNC ;
q->name = new_STRING("/dev/stderr") ;
q->ptr = (PTR) stderr ;
- file_list = q ;
+
+ p = ZMALLOC(FILE_NODE) ;
+ p->link = q;
+ p->type = F_TRUNC ;
+ p->name = new_STRING("/dev/stdout") ;
+ p->ptr = (PTR) stdout ;
+
+ file_list = p ;
}
/* fopen() but no buffering to ttys */
@@ -619,3 +646,13 @@
}
}
#endif /* MSDOS */
+
+/* An error occured closing the file referred to by P. We tell the
+ user and terminate the program. */
+
+static void close_error(p)
+ FILE_NODE *p ;
+{
+ errmsg(errno, "close failed on file %s", p->name->str) ;
+ mawk_exit(2) ;
+}
Information forwarded to debian-bugs-dist@lists.debian.org, James Troup <awkmaint@nocrew.org>:
Bug#4293; Package mawk.
debian-bugs-dist@lists.debian.orgJames Troup
Subject: Bug#4293: mawk
Reply-To: Christian Kurz , 4293@bugs.debian.org
Resent-From: Christian Kurz
Resent-To: debian-bugs-dist@lists.debian.org
Resent-CC: James Troup
Resent-Date: Wed, 14 Apr 1999 21:03:04 GMT
Resent-Message-ID:
Resent-Sender: iwj@debian.org
X-Debian-PR-Message: report 4293
X-Debian-PR-Package: mawk
X-Debian-PR-Keywords:
X-Loop: owner@bugs.debian.org
Received: via spool by 4293-bugs@bugs.debian.org id=B4293.92412317711496
(code B ref 4293); Wed, 14 Apr 1999 21:03:04 GMT
Date: Wed, 14 Apr 1999 22:44:57 +0200
From: Christian Kurz
To: 4293@bugs.debian.org
Message-ID: <19990414224457.H298@jupiter.rhein-neckar.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
User-Agent: Mutt/0.96.1i
Organization: Core Dumped
Hi,
could you please apply the patch from Torsten Landschoff and close this
bug report now? Thanks for doing so.
Cheers
Christian
--
In just seven days, I can make you a man!
-- The Rocky Horror Picture Show
/* http://www.rhein-neckar.de/~jupiter/ Stardate: 36260.5 */
Acknowledgement sent to Christian Kurz <shorty@debian.org>:
Extra info received and forwarded to list. Copy sent to James Troup <awkmaint@nocrew.org>.
-t
From: owner@bugs.debian.org (Debian Bug Tracking System)
To: Christian Kurz
Subject: Bug#4293: Info received (was mawk)
Message-ID:
In-Reply-To: <19990414224457.H298@jupiter.rhein-neckar.de>
References: <19990414224457.H298@jupiter.rhein-neckar.de>
X-Debian-PR-Message: ack-info-maintonly 4293
Thank you for the additional information you have supplied regarding
this problem report. It has been forwarded to the developer(s) and
to the developers' mailing list to accompany the original report.
Your message has been sent to the package maintainer(s):
James Troup
If you wish to continue to submit further information on your problem,
please send it to 4293@bugs.debian.org, as before.
Please do not reply to the address at the top of this message,
unless you wish to report a problem with the bug-tracking system.
Ian Jackson
(administrator, Debian bugs database)
Received: (at 4293) by bugs.debian.org; 14 Apr 1999 20:52:57 +0000
Received: (qmail 11488 invoked from network); 14 Apr 1999 20:52:57 -0000
Received: from news-ma.rhein-neckar.de (193.197.90.3)
by master.debian.org with SMTP; 14 Apr 1999 20:52:57 -0000
Received: from jupiter.rhein-neckar.de (uucp@localhost)
by news-ma.rhein-neckar.de (8.8.8/8.8.8) with bsmtp id WAA05838
for 4293@bugs.debian.org; Wed, 14 Apr 1999 22:52:55 +0200 (CEST)
(envelope-from shorty@debian.org)
Received: by jupiter.rhein-neckar.de with local (Exim 2.11)
id 10XWWn-0001OD-00
for 4293@bugs.debian.org; Wed, 14 Apr 1999 22:44:57 +0200
Date: Wed, 14 Apr 1999 22:44:57 +0200
From: Christian Kurz
To: 4293@bugs.debian.org
Subject: mawk
Message-ID: <19990414224457.H298@jupiter.rhein-neckar.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
User-Agent: Mutt/0.96.1i
Organization: Core Dumped
Hi,
could you please apply the patch from Torsten Landschoff and close this
bug report now? Thanks for doing so.
Cheers
Christian
--
In just seven days, I can make you a man!
-- The Rocky Horror Picture Show
/* http://www.rhein-neckar.de/~jupiter/ Stardate: 36260.5 */
Information forwarded to debian-bugs-dist@lists.debian.org, James Troup <awkmaint@nocrew.org>:
Bug#4293; Package mawk.
debian-bugs-dist@lists.debian.orgJames Troup
Subject: Bug#4293: Fixed package at www.debian.org...
Reply-To: Torsten Landschoff , 4293@bugs.debian.org
Resent-From: Torsten Landschoff
Resent-To: debian-bugs-dist@lists.debian.org
Resent-CC: James Troup
Resent-Date: Sat, 05 Jun 1999 10:18:00 GMT
Resent-Message-ID:
Resent-Sender: iwj@debian.org
X-Debian-PR-Message: report 4293
X-Debian-PR-Package: mawk
X-Debian-PR-Keywords:
X-Loop: owner@bugs.debian.org
Received: via spool by 4293-bugs@bugs.debian.org id=B4293.92857710227215
(code B ref 4293); Sat, 05 Jun 1999 10:18:00 GMT
Date: Sat, 5 Jun 1999 12:05:45 +0200
From: Torsten Landschoff
To: 4293@bugs.debian.org
Message-ID: <19990605120544.C15674@wormhole.galaxy>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Mailer: Mutt 0.94.17i
Hiho!
I came back to my patch to make a fixed package available. Problem:
The patch from the BTS does not apply and is some bytes bigger than my
local version.
You can find the fix at http://www.debian.org/~torsten/qa/4293/ -
there is a new diff also.
Thanks
Torsten
Acknowledgement sent to Torsten Landschoff <t.landschoff@gmx.net>:
Extra info received and forwarded to list. Copy sent to James Troup <awkmaint@nocrew.org>.
-t
From: owner@bugs.debian.org (Debian Bug Tracking System)
To: Torsten Landschoff
Subject: Bug#4293: Info received (was Fixed package at www.debian.org...)
Message-ID:
In-Reply-To: <19990605120544.C15674@wormhole.galaxy>
References: <19990605120544.C15674@wormhole.galaxy>
X-Debian-PR-Message: ack-info-maintonly 4293
Thank you for the additional information you have supplied regarding
this problem report. It has been forwarded to the developer(s) and
to the developers' mailing list to accompany the original report.
Your message has been sent to the package maintainer(s):
James Troup
If you wish to continue to submit further information on your problem,
please send it to 4293@bugs.debian.org, as before.
Please do not reply to the address at the top of this message,
unless you wish to report a problem with the bug-tracking system.
Ian Jackson
(administrator, Debian bugs database)
Received: (at 4293) by bugs.debian.org; 5 Jun 1999 10:05:02 +0000
Received: (qmail 27212 invoked from network); 5 Jun 1999 10:05:02 -0000
Received: from authsrv.nacamar.de (HELO dialup.nacamar.de) (194.162.162.197)
by master.debian.org with SMTP; 5 Jun 1999 10:05:02 -0000
Received: (qmail 26874 invoked from network); 5 Jun 1999 10:05:00 -0000
Received: from dialup18-97.access.nacamar.de (HELO wormhole.galaxy) (torsten@62.144.239.97)
by authsrv.nacamar.de with SMTP; 5 Jun 1999 10:05:00 -0000
Received: (from torsten@localhost)
by wormhole.galaxy (8.8.8/8.8.8/Debian/GNU) id MAA16231
for 4293@bugs.debian.org; Sat, 5 Jun 1999 12:05:46 +0200
Date: Sat, 5 Jun 1999 12:05:45 +0200
From: Torsten Landschoff
To: 4293@bugs.debian.org
Subject: Fixed package at www.debian.org...
Message-ID: <19990605120544.C15674@wormhole.galaxy>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Mailer: Mutt 0.94.17i
Hiho!
I came back to my patch to make a fixed package available. Problem:
The patch from the BTS does not apply and is some bytes bigger than my
local version.
You can find the fix at http://www.debian.org/~torsten/qa/4293/ -
there is a new diff also.
Thanks
Torsten
Reply sent to James Troup <james@nocrew.org>:
You have taken responsibility.
-t
From: owner@bugs.debian.org (Debian Bug Tracking System)
To: James Troup
Cc: James Troup
Bcc: debian-bugs-closed@lists.debian.org
Subject: Bug#4293: marked as done (mawk doesn't report an error on full filesystems)
Message-ID:
In-Reply-To: <87r9j3o1kf.fsf@nocrew.org>
References: <87r9j3o1kf.fsf@nocrew.org> <199608261243.OAA02314@ion.lpr.e-technik.tu-muenchen.de>
X-Debian-PR-Message: closed 4293
Your message dated 10 Oct 1999 13:14:08 +0100
with message-id <87r9j3o1kf.fsf@nocrew.org>
and subject line mawk doesn't report an error on full filesystems
has caused the attached Bug report to be marked as done.
This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.
(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere. Please contact me immediately.)
Darren Benham
(administrator, Debian Bugs database)
--------------------------------------
Received: (at submit) by bugs.debian.org; 26 Aug 1996 15:14:12 +0000
Received: (qmail-queue invoked from smtpd); 26 Aug 1996 15:09:01 -0000
Received: from spock.lpr.e-technik.tu-muenchen.de (root@129.187.151.1)
by master.debian.org with SMTP; 26 Aug 1996 15:08:57 -0000
Received: from ion.lpr.e-technik.tu-muenchen.de (ion.lpr.e-technik.tu-muenchen.de [129.187.151.28]) by spock.lpr.e-technik.tu-muenchen.de (8.6.12/8.6.6) with ESMTP id RAA17379; Mon, 26 Aug 1996 17:03:35 +0200
Received: (from thielen@localhost) by ion.lpr.e-technik.tu-muenchen.de (8.7.5/8.7.3) id OAA02314; Mon, 26 Aug 1996 14:43:48 +0200
From: Herbert Thielen
Message-Id: <199608261243.OAA02314@ion.lpr.e-technik.tu-muenchen.de>
Subject: mawk doesn't report an error on full filesystems
To: submit@bugs.debian.org
Date: Mon, 26 Aug 1996 14:43:47 +0200 (MET DST)
Cc: herbert.thielen@lpr.e-technik.tu-muenchen.de
X-Mailer: ELM [version 2.4 PL24 ME7a]
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Package: mawk
Version: 1.2.2-1
Mawk doesn't report an error when writing to a full filesystem:
$ mawk '{print}' < /etc/motd > /dev/full
$ echo $?
0
Probably no write error is catched. Gawk does it's job correct:
$ gawk '{print}' < /etc/motd > /dev/full
gawk: cmd. line:1: (FILENAME=- FNR=9) warning: error writing standard output (No space left on device)
Regards
Herbert.
---------------------------------------
Received: (at 4293-done) by bugs.debian.org; 10 Oct 1999 12:14:12 +0000
Received: (qmail 5409 invoked from network); 10 Oct 1999 12:14:11 -0000
Received: from finch-post-10.mail.demon.net (194.217.242.38)
by master.debian.org with SMTP; 10 Oct 1999 12:14:11 -0000
Received: from ruari-quinn.demon.co.uk ([158.152.170.83] helo=cookie)
by finch-post-10.mail.demon.net with esmtp (Exim 2.12 #1)
id 11aHre-00071U-0A
for 4293-done@bugs.debian.org; Sun, 10 Oct 1999 12:14:10 +0000
Received: from james by cookie with local (Exim 2.11 #1 (Debian))
id 11aHrc-000075-00; Sun, 10 Oct 1999 13:14:08 +0100
To: 4293-done@bugs.debian.org
Subject: Re: mawk doesn't report an error on full filesystems
Mail-Copies-To: never
From: James Troup
Date: 10 Oct 1999 13:14:08 +0100
Message-ID: <87r9j3o1kf.fsf@nocrew.org>
Lines: 20
User-Agent: Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.3
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Sender: James Troup
Herbert Thielen writes:
> Package: mawk
> Version: 1.2.2-1
>
> Mawk doesn't report an error when writing to a full filesystem:
>
> $ mawk '{print}' < /etc/motd > /dev/full
> $ echo $?
> 0
>
> Probably no write error is catched. Gawk does it's job correct:
>
> $ gawk '{print}' < /etc/motd > /dev/full
> gawk: cmd. line:1: (FILENAME=- FNR=9) warning: error writing standard output (No space left on device)
Fixed by a patch from Torsten Landschoff in mawk 1.3.3-3.
--
James
Notification sent to Herbert Thielen <Herbert.Thielen@lpr.e-technik.tu-muenchen.de>:
Bug acknowledged by developer.
-t
From: owner@bugs.debian.org (Debian Bug Tracking System)
To: Herbert Thielen
Subject: Bug#4293 acknowledged by developer (mawk doesn't report an error on full filesystems)
Message-ID:
In-Reply-To: <199608261243.OAA02314@ion.lpr.e-technik.tu-muenchen.de>
References: <87r9j3o1kf.fsf@nocrew.org> <199608261243.OAA02314@ion.lpr.e-technik.tu-muenchen.de>
X-Debian-PR-Message: they-closed 4293
This is an automatic notification regarding your Bug report.
It has been closed by one of the developers, namely
James Troup .
Their explanation is attached below. If this explanation is
unsatisfactory and you have not received a better one in a separate
message then please contact the developer directly, or email
submit@bugs.debian.org or me.
Darren Benham
(administrator, Debian Bugs database)
Received: (at 4293-done) by bugs.debian.org; 10 Oct 1999 12:14:12 +0000
Received: (qmail 5409 invoked from network); 10 Oct 1999 12:14:11 -0000
Received: from finch-post-10.mail.demon.net (194.217.242.38)
by master.debian.org with SMTP; 10 Oct 1999 12:14:11 -0000
Received: from ruari-quinn.demon.co.uk ([158.152.170.83] helo=cookie)
by finch-post-10.mail.demon.net with esmtp (Exim 2.12 #1)
id 11aHre-00071U-0A
for 4293-done@bugs.debian.org; Sun, 10 Oct 1999 12:14:10 +0000
Received: from james by cookie with local (Exim 2.11 #1 (Debian))
id 11aHrc-000075-00; Sun, 10 Oct 1999 13:14:08 +0100
To: 4293-done@bugs.debian.org
Subject: Re: mawk doesn't report an error on full filesystems
Mail-Copies-To: never
From: James Troup
Date: 10 Oct 1999 13:14:08 +0100
Message-ID: <87r9j3o1kf.fsf@nocrew.org>
Lines: 20
User-Agent: Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.3
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Sender: James Troup
Herbert Thielen writes:
> Package: mawk
> Version: 1.2.2-1
>
> Mawk doesn't report an error when writing to a full filesystem:
>
> $ mawk '{print}' < /etc/motd > /dev/full
> $ echo $?
> 0
>
> Probably no write error is catched. Gawk does it's job correct:
>
> $ gawk '{print}' < /etc/motd > /dev/full
> gawk: cmd. line:1: (FILENAME=- FNR=9) warning: error writing standard output (No space left on device)
Fixed by a patch from Torsten Landschoff in mawk 1.3.3-3.
--
James
Received: (at 4293-done) by bugs.debian.org; 10 Oct 1999 12:14:12 +0000
Received: (qmail 5409 invoked from network); 10 Oct 1999 12:14:11 -0000
Received: from finch-post-10.mail.demon.net (194.217.242.38)
by master.debian.org with SMTP; 10 Oct 1999 12:14:11 -0000
Received: from ruari-quinn.demon.co.uk ([158.152.170.83] helo=cookie)
by finch-post-10.mail.demon.net with esmtp (Exim 2.12 #1)
id 11aHre-00071U-0A
for 4293-done@bugs.debian.org; Sun, 10 Oct 1999 12:14:10 +0000
Received: from james by cookie with local (Exim 2.11 #1 (Debian))
id 11aHrc-000075-00; Sun, 10 Oct 1999 13:14:08 +0100
To: 4293-done@bugs.debian.org
Subject: Re: mawk doesn't report an error on full filesystems
Mail-Copies-To: never
From: James Troup
Date: 10 Oct 1999 13:14:08 +0100
Message-ID: <87r9j3o1kf.fsf@nocrew.org>
Lines: 20
User-Agent: Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.3
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Sender: James Troup
Herbert Thielen writes:
> Package: mawk
> Version: 1.2.2-1
>
> Mawk doesn't report an error when writing to a full filesystem:
>
> $ mawk '{print}' < /etc/motd > /dev/full
> $ echo $?
> 0
>
> Probably no write error is catched. Gawk does it's job correct:
>
> $ gawk '{print}' < /etc/motd > /dev/full
> gawk: cmd. line:1: (FILENAME=- FNR=9) warning: error writing standard output (No space left on device)
Fixed by a patch from Torsten Landschoff in mawk 1.3.3-3.
--
James