-1

The POSIX System Interface Specification says:

The default action for SIGCONT is to resume execution at the point where the process was stopped, after first handling any pending unblocked signals.

What does "after" mean here? Shouldn't it be "before" instead? Is there some example to show what it means?

Similarly from APUE:

Since the process group is orphaned when the parentterminates, POSIX.1 requires that every process in the newly orphaned process group that is stopped (as our child is) be sent the hang-up signal (SIGHUP) followed by the continue signal (SIGCONT)

This causes the child to be continued, after processing the hang-up signal. The default action for the hang-up signal is to terminate the process, so we have to provide a signal handler to catch the signal. We therefore expect the printf in the sig_hup function to appear before the printf in the pr_ids function.

Shouldn't "after" be "before" instead?

At order of SIGCONT and SIGHUP sent to orphaned linux process group seems to suggest "before" instead of "after" in the above two quotes, or I misunderstand it:

The SIGHUP cannot be delivered until the child's execution is resumed. When a process is stopped, all signal delivery is suspended except for SIGCONT and SIGKILL.

So, the SIGHUP does arrive first, but it cannot be processed until the SIGCONT awakens the process execution.

Thanks.

When several signals arrive at a process, what is the order between the process handling the signals?

AdminBee
  • 22,803
Tim
  • 101,790

2 Answers2

4

No, it means after. The key is "resume execution at the point where the process was stopped".

Signal processing is performed first, and then execution continues.

3

signal.c POSIX 1b compliant signal kernel code

Do a search on SIGCONT. You will see that when SIGCONT is encountered the code then looks for pending signals.

Manuel Jordan
  • 1,728
  • 2
  • 16
  • 40
  • Thanks. Could you point out which line in the source file is for "when SIGCONT is encountered the code then looks for pending signals"? – Tim Dec 24 '18 at 21:10
  • Try the comments found on lines 661, 862, 2028. Reading the code is time consuming , so consider starting with comments. If you search on "SIGCONT" you will find all of the comments and some of the relevant lines of code. – jim mcnamara Dec 25 '18 at 05:07