GNU bug report logs -
#47596
File descriptor error when exiting emacs on android 11
Previous Next
Reported by: Henrik Grimler <henrik <at> grimler.se>
Date: Sun, 4 Apr 2021 19:21:02 UTC
Severity: normal
Tags: moreinfo
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
Message #41 received at 47596 <at> debbugs.gnu.org (full text, mbox):
Hi Lars,
On Thu, 2021-05-06 at 12:45 +0200, Lars Ingebrigtsen wrote:
> > I probably should have included a bit more context in the android bug
> > report to better show what the code does.
>
> Did you try to include this context in the Android bug report and see
> what they say then?
>
I added another comment now with a slightly more verbose example:
```
#include <stdlib.h>
#include <unistd.h>
/* If FD is not already open, arrange for it to be open with FLAGS. */
static void
force_open (int fd, int flags)
{
if (dup2 (fd, fd) < 0)
{
int n = open ("/dev/null", flags);
if (n < 0 || (fd != n && (dup2 (n, fd) < 0 || close (n) == 0 !=
0)))
exit (EXIT_FAILURE);
}
}
/* A stream that is like stderr, except line buffered. It is NULL
during startup, or if line buffering is not in use. */
static FILE *buferr;
int
main()
{
/* Make sure stderr are open to something, so that the file
descriptor is not hijacked by later system calls. */
force_open (STDERR_FILENO, O_RDONLY);
/* Set buferr if possible on platforms defining _PC_PIPE_BUF, as
they support the notion of atomic writes to pipes. */
#ifdef _PC_PIPE_BUF
buferr = fdopen (STDERR_FILENO, "w");
if (buferr)
setvbuf (buferr, NULL, _IOLBF, 0);
#endif
int err = buferr && (fflush (buferr) != 0 || ferror (buferr));
if (err | (fclose (stderr) != 0))
return 1;
return 0;
}
```
Hopefully they have time to provide some feedback.
Best regards,
Henrik Grimler
This bug report was last modified 2 years and 324 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.