mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Igmar Palsenberg <igmar@palsenberg.com>
To: musl@lists.openwall.com
Subject: Re: abort() PID 1
Date: Mon, 4 Jul 2016 10:28:22 +0200 (CEST)	[thread overview]
Message-ID: <alpine.LRH.2.20.1607041023420.21514@s1.palsenberg.com> (raw)
In-Reply-To: <CAKpSnpJvJAktWS+i+ncEuU5i3apeYCqTPtjUfMn4gkyc3mwvdg@mail.gmail.com>



> The recent thread about abort() and PID 1 left me in a state of
> confusion, in a matter I thought was clear enough:
> 
> What I thought I understood:
> 
> - the kernel will not deliver any signal to process 1, unless a signal
> handler for that particular signal has been installed
> 
> -if process 1 calls abort() (regardless of what purpose that would fill), then:
> 
>     - if a handler was setup, it should be done whatever the handler does
> 
>     - if a handler was not setup, nothing should happen (as in:
> process didn't receive any signal at all)

Pid 1 can ignore sigkill / sigstop. "Normal" processes can't. "Normal" 
processes have defaults handling signals, pid 1 ignores all by default, 
unless it instructs the kernel it wants to receive it. 

> 
> What the standards say:
> 
> (http://pubs.opengroup.org/onlinepubs/9699919799/)
> 
> "The SIGABRT signal shall be sent to the calling process as if by
> means of raise() with the argument SIGABRT."
> 
> "The effect of the raise() function shall be equivalent to calling:
> 
> pthread_kill(pthread_self(), sig);"
> 
> man raise(3):
> The  raise()  function  sends  a  signal  to the caling process or
> thread.  In a single-threaded program it is equivalent to
> kill(getpid(), sig);
> 
> So, what should " kill(1, SIGABRT)" do? It doesn't seem ambiguous to
> me. IOW, there's nothing special about SIGABRT regarding PID 1.

The "problem" in this case is that the "normal" abort() sends a SIGABRT, 
if that doesn't work, unblocks signals and retries.
While that works with "normal" processes, it doesn't work with pid 1, 
because the default action on that process for SIGABRT isn't terminate.

Hence the infinite loop you see. IMHO, we should leave this as it is, 
unless the abort() call fails to successfully terminate the process on 
non-pid 1 processes. That is a bug, failing to terminate pid 1 isn't.




Igmar


  reply	other threads:[~2016-07-04  8:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-04  8:09 Jorge Almeida
2016-07-04  8:28 ` Igmar Palsenberg [this message]
2016-07-04  9:37   ` Jorge Almeida
2016-07-04  9:31 ` Szabolcs Nagy
2016-07-04  9:49   ` Jorge Almeida
2016-07-04 13:30   ` Igmar Palsenberg
2016-07-05  3:14     ` Rich Felker

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=alpine.LRH.2.20.1607041023420.21514@s1.palsenberg.com \
    --to=igmar@palsenberg.com \
    --cc=musl@lists.openwall.com \
    /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 public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).