all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Henrik Grimler <henrik@grimler.se>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 47596@debbugs.gnu.org
Subject: bug#47596: File descriptor error when exiting emacs on android 11
Date: Mon, 10 May 2021 09:23:05 +0200	[thread overview]
Message-ID: <8a9fbefead009fce76aa5a28315c0fedf3ce7bec.camel@grimler.se> (raw)
In-Reply-To: <87k0ocw37m.fsf@gnus.org>

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






  reply	other threads:[~2021-05-10  7:23 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-04 19:20 bug#47596: File descriptor error when exiting emacs on android 11 Henrik Grimler
2021-04-04 19:31 ` Eli Zaretskii
2021-04-04 20:11   ` Henrik Grimler
2021-04-05  8:14     ` Henrik Grimler
2021-04-05  8:59       ` Henrik Grimler
2021-04-05  9:48         ` Henrik Grimler
2021-04-05 12:57           ` Eli Zaretskii
2021-04-05 13:38             ` Henrik Grimler
2021-04-05 12:52         ` Eli Zaretskii
2021-04-05 12:50       ` Eli Zaretskii
2021-04-05 17:29         ` Henrik Grimler
2021-05-06 10:45           ` Lars Ingebrigtsen
2021-05-10  7:23             ` Henrik Grimler [this message]
2021-05-11 17:06               ` Henrik Grimler
2021-05-12 13:52                 ` Lars Ingebrigtsen
2021-05-12 14:01                   ` Eli Zaretskii
2022-06-29 10:47                     ` Lars Ingebrigtsen
2022-06-29 13:25                       ` Henrik Grimler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-06-30  9:07                         ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8a9fbefead009fce76aa5a28315c0fedf3ce7bec.camel@grimler.se \
    --to=henrik@grimler.se \
    --cc=47596@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.