[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 3.1.6 system() fails when at the ulimit of open files
From: |
Aharon Robbins |
Subject: |
Re: 3.1.6 system() fails when at the ulimit of open files |
Date: |
Fri, 16 Oct 2009 08:49:54 +0200 |
Andreas,
You're right. That's what I get for coding late at night. Attached is
a follow-on diff.
Thanks,
Arnold
----------------------------------------------------------
Fri Oct 16 08:41:29 2009 Arnold D. Robbins <address@hidden>
* io.c (redirect): Do the close-on-exec setting before
attempt to get a FILE *. Thanks to Andreas Schwab.
Index: io.c
===================================================================
RCS file: /d/mongo/cvsrep/gawk-stable/io.c,v
retrieving revision 1.24
diff -u -r1.24 io.c
--- io.c 14 Oct 2009 21:29:57 -0000 1.24
+++ io.c 16 Oct 2009 06:48:33 -0000
@@ -731,16 +731,16 @@
else if (fd == fileno(stderr))
rp->fp = stderr;
else {
+ const char *omode = mode;
#if defined(F_GETFL) && defined(O_APPEND)
int fd_flags;
fd_flags = fcntl(fd, F_GETFL);
if (fd_flags != -1 && (fd_flags &
O_APPEND) == O_APPEND)
- rp->fp = fdopen(fd,
binmode("a"));
- else
+ omode = binmode("a");
#endif
- rp->fp = fdopen(fd, (const char
*) mode);
- os_close_on_exec(fileno(rp->fp), str,
"file", "");
+ os_close_on_exec(fd, str, "file", "");
+ rp->fp = fdopen(fd, (const char *)
omode);
rp->mode = (const char *) mode;
/* don't leak file descriptors */
if (rp->fp == NULL)
> From: Andreas Schwab <address@hidden>
> To: Aharon Robbins <address@hidden>
> Cc: address@hidden, address@hidden, address@hidden
> Subject: Re: 3.1.6 system() fails when at the ulimit of open files
> Date: Thu, 15 Oct 2009 01:25:45 +0200
>
> Aharon Robbins <address@hidden> writes:
>
> > Index: io.c
> > ===================================================================
> > RCS file: /d/mongo/cvsrep/gawk-stable/io.c,v
> > retrieving revision 1.23
> > diff -u -r1.23 io.c
> > --- io.c 9 Jul 2009 19:54:38 -0000 1.23
> > +++ io.c 14 Oct 2009 21:24:12 -0000
> > @@ -740,6 +740,7 @@
> > else
> > #endif
> > rp->fp = fdopen(fd, (const char
> > *) mode);
> > + os_close_on_exec(fileno(rp->fp), str,
> > "file", "");
> > rp->mode = (const char *) mode;
> > /* don't leak file descriptors */
> > if (rp->fp == NULL)
>
> If this is true then you crash above.
>
> Andreas.
>
> --
> Andreas Schwab, address@hidden
> GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
> "And now for something completely different."
>