#2088 PR merged: Error function must immediately exit (issue #2089)

Labels: fixed / solved / done, critical / security / legal

jsmeix opened issue at 2019-03-18 10:46:

By me on openSUSE Leap 15.0 with artificial Error calls
in a script directly as

Error "Test error"

and in a subshell as

( Error "Test error" )
  • Brief description of the changes in this pull request:

The Error function must not return to its caller
because then the caller could continue with the code
after its Error function call, see
https://github.com/rear/rear/issues/2089#issuecomment-474240386

jsmeix commented at 2019-03-18 10:49:

@rear/contributors
if one of you has a better understanding
how to cleanly abort via the Error function
without possibly running further code after the Error function call
I would appreciate information how to better implement things.

jsmeix commented at 2019-03-18 11:03:

FYI
how the log for
https://github.com/rear/rear/issues/2087#issue-421604286
in
https://github.com/rear/rear/files/2972012/rear-testvm02.log
looks (excerpts):

+++ Error 'Partition number '\''0'\'' of partition mmcblk0boot0 is not a valid number.'
...
+++ kill -USR1 15126
+++ ((  0 <= 128  ))
+++ StopIfError 'Partition mmcblk0boot0 is numbered '\''0'\''. More than 128 partitions is not supported.'
...
+++ Error 'Partition number '\'''\'' of partition mmcblk0rpmb is not a valid number.'
...
+++ kill -USR1 15126
+++ ((   <= 128  ))
...
+++ Error 'Partition mmcblk0rpmb is numbered '\'''\''. More than 128 partitions is not supported.'
...
+++ kill -USR1 15126
...
[ here in between are 549 lines of debug messages about further executed code ]
...
++ EXIT_FAIL_MESSAGE=0
++ echo 'Aborting due to an error, check /var/log/rear/rear-testvm02.log for details'
++ kill 15126
++ DoExitTasks

versus how it looks for me with my sleep 1 at the end of the Error function

++ kill -USR1 10714
++ sleep 1
+++ EXIT_FAIL_MESSAGE=0
+++ echo 'Aborting due to an error, check /root/rear.github.master/var/log/rear/rear-g243.log for details'
+++ kill 10714
+++ DoExitTasks

jsmeix commented at 2019-03-18 12:29:

https://github.com/rear/rear/issues/2087#issuecomment-473884096
shows that the sleep 1 at the end of the Error function is useless
so it seems something more severe is going on here...

rmetrich commented at 2019-03-18 12:35:

I'm pretty sure it's due to how buffering is performed.
IMHO, stderr is unbuffered whereas stdout is.

jsmeix commented at 2019-03-18 15:07:

As far as I see the root cause is
https://github.com/rear/rear/issues/2089#issuecomment-473908710
and my latest
https://github.com/rear/rear/pull/2088/commits/cfd440158f7fd56fbc94835d2111f2d81176eb95
implements what "helps a bit" in
https://github.com/rear/rear/issues/2089#issuecomment-473919956
as a first step to actually solve it.

jsmeix commented at 2019-03-18 17:30:

My latest commit here
https://github.com/rear/rear/pull/2088/commits/d9a02ad1397331a2fbf24515311e3c30271e43e5
is some bigger changes and perhaps too much code
but at least for now things seem to work for me
after a quick test (more testing tomorrow):

Now

LogPrint "$( pstree -Aplau $MASTER_PID || ps f -g $MASTER_PID -o pid,args || ps --ppid $MASTER_PID -o pid,args )"
( LogPrint "First subshell"
  LogPrint "$( pstree -Aplau $MASTER_PID || ps f -g $MASTER_PID -o pid,args || ps --ppid $MASTER_PID -o pid,args )"
  ( LogPrint "Second subshell"
    LogPrint "$( pstree -Aplau $MASTER_PID || ps f -g $MASTER_PID -o pid,args || ps --ppid $MASTER_PID -o pid,args )"
    Error "Test error a"
    Error "Test error b"
  )
  LogPrint "Code in first subshell after second subshell"
  echo "foo" >/tmp/rear_test_file
  LogPrint "$( cat /tmp/rear_test_file )"
  rm -v /tmp/rear_test_file 0<&6 1>&7 2>&8
  LogPrint "End of first subshell"
)
LogPrint "Message after first subshell"

errors out correctly - as far as I see - as follows:

# usr/sbin/rear -D mkrescue
Relax-and-Recover 2.4 / Git
Running rear mkrescue (PID 6099)
Using log file: /root/rear.github.master/var/log/rear/rear-g243.log
rear,6099 usr/sbin/rear -D mkrescue
  `-rear,6317 usr/sbin/rear -D mkrescue
      `-pstree,6318 -Aplau 6099
First subshell
rear,6099 usr/sbin/rear -D mkrescue
  `-rear,6321 usr/sbin/rear -D mkrescue
      `-rear,6324 usr/sbin/rear -D mkrescue
          `-pstree,6325 -Aplau 6099
Second subshell
rear,6099 usr/sbin/rear -D mkrescue
  `-rear,6321 usr/sbin/rear -D mkrescue
      `-rear,6328 usr/sbin/rear -D mkrescue
          `-rear,6331 usr/sbin/rear -D mkrescue
              `-pstree,6332 -Aplau 6099
ERROR: Test error a
Some latest log messages since the last called script 030_update_recovery_system.sh:
    `-rear,6321 usr/sbin/rear -D mkrescue
        `-rear,6328 usr/sbin/rear -D mkrescue
            `-rear,6331 usr/sbin/rear -D mkrescue
                `-pstree,6332 -Aplau 6099
    `-rear,6321 usr/sbin/rear -D mkrescue
        `-rear,6328 usr/sbin/rear -D mkrescue
            `-rear,6331 usr/sbin/rear -D mkrescue
                `-pstree,6332 -Aplau 6099'
Error exit of rear mkrescue (PID 6099) and its descendant processes
Terminating descendant process 6321 /bin/bash usr/sbin/rear -D mkrescue
Aborting due to an error, check /root/rear.github.master/var/log/rear/rear-g243.log for details
Exiting rear mkrescue (PID 6099) and its descendant processes
Terminating descendant process 6328 /bin/bash usr/sbin/rear -D mkrescue
Running exit tasks
Terminated

A normal Error() not in a subshell like

LogPrint "$( pstree -Aplau $MASTER_PID || ps f -g $MASTER_PID -o pid,args || ps --ppid $MASTER_PID -o pid,args )"
Error "Test error"
LogPrint "Message after Error"

errors out this way:

# usr/sbin/rear -D mkrescue
Relax-and-Recover 2.4 / Git
Running rear mkrescue (PID 6727)
Using log file: /root/rear.github.master/var/log/rear/rear-g243.log
rear,6727 usr/sbin/rear -D mkrescue
  `-rear,6944 usr/sbin/rear -D mkrescue
      `-pstree,6945 -Aplau 6727
ERROR: Test error
Some latest log messages since the last called script 030_update_recovery_system.sh:
        `-pstree,6945 -Aplau 6727'
    `-rear,6944 usr/sbin/rear -D mkrescue
        `-pstree,6945 -Aplau 6727'
  2019-03-18 18:29:09.005623275 rear,6727 usr/sbin/rear -D mkrescue
    `-rear,6944 usr/sbin/rear -D mkrescue
        `-pstree,6945 -Aplau 6727
    `-rear,6944 usr/sbin/rear -D mkrescue
        `-pstree,6945 -Aplau 6727'
Aborting due to an error, check /root/rear.github.master/var/log/rear/rear-g243.log for details
Exiting rear mkrescue (PID 6727) and its descendant processes
Running exit tasks
Terminated

jsmeix commented at 2019-03-18 18:18:

FYI
how it errors out without pstree -Aplau $MASTER_PID commands

( LogPrint "First subshell"
  ( LogPrint "Second subshell"
    Error "Test error a"
    Error "Test error b"
  )
  LogPrint "Code in first subshell after second subshell"
  LogPrint "End of first subshell"
)
LogPrint "Message after first subshell"

that errors out like

# usr/sbin/rear -D mkrescue
Relax-and-Recover 2.4 / Git
Running rear mkrescue (PID 10422)
Using log file: /root/rear.github.master/var/log/rear/rear-g243.log
First subshell
Second subshell
ERROR: Test error a
Some latest log messages since the last called script 030_update_recovery_system.sh:
  2019-03-18 19:18:14.074503193 Including init/default/030_update_recovery_system.sh
  2019-03-18 19:18:14.075294725 Entering debugscripts mode via 'set -x'.
  2019-03-18 19:18:14.078691835 First subshell
  2019-03-18 19:18:14.080233165 Second subshell
Error exit of rear mkrescue (PID 10422) and its descendant processes
Terminating descendant process 10639 /bin/bash usr/sbin/rear -D mkrescue
Aborting due to an error, check /root/rear.github.master/var/log/rear/rear-g243.log for details
Exiting rear mkrescue (PID 10422) and its descendant processes
Terminating descendant process 10642 /bin/bash usr/sbin/rear -D mkrescue
Running exit tasks
Terminated

and a plain

Error "Test error"
LogPrint "Message after Error"

errors out like

# usr/sbin/rear -D mkrescue
Relax-and-Recover 2.4 / Git
Running rear mkrescue (PID 10751)
Using log file: /root/rear.github.master/var/log/rear/rear-g243.log
ERROR: Test error
Some latest log messages since the last called script 030_update_recovery_system.sh:
  2019-03-18 19:19:17.796780805 Including init/default/030_update_recovery_system.sh
  2019-03-18 19:19:17.797625940 Entering debugscripts mode via 'set -x'.
Aborting due to an error, check /root/rear.github.master/var/log/rear/rear-g243.log for details
Exiting rear mkrescue (PID 10751) and its descendant processes
Running exit tasks
Terminated

jsmeix commented at 2019-03-18 18:27:

Something is not yet fully clean in case of three nested subshells

( LogPrint "First subshell"
  ( LogPrint "Second subshell"
    ( LogPrint "Third subshell"
      Error "Test error a"
      Error "Test error b"
    )
    LogPrint "Code in second subshell after third subshell"
    LogPrint "End of second subshell"
  )
  LogPrint "Code in first subshell after second subshell"
  LogPrint "End of first subshell"
)
LogPrint "Message after first subshell"

which errors out this way:

# usr/sbin/rear -D mkrescue
Relax-and-Recover 2.4 / Git
Running rear mkrescue (PID 11824)
Using log file: /root/rear.github.master/var/log/rear/rear-g243.log
First subshell
Second subshell
Third subshell
ERROR: Test error a
Some latest log messages since the last called script 030_update_recovery_system.sh:
  2019-03-18 19:24:32.338361366 Including init/default/030_update_recovery_system.sh
  2019-03-18 19:24:32.339156300 Entering debugscripts mode via 'set -x'.
  2019-03-18 19:24:32.342579301 First subshell
  2019-03-18 19:24:32.344089500 Second subshell
  2019-03-18 19:24:32.345597625 Third subshell
Error exit of rear mkrescue (PID 11824) and its descendant processes
Terminating descendant process 12047 /bin/bash usr/sbin/rear -D mkrescue
Aborting due to an error, check /root/rear.github.master/var/log/rear/rear-g243.log for details
Exiting rear mkrescue (PID 11824) and its descendant processes
Terminating descendant process 12050 /bin/bash usr/sbin/rear -D mkrescue
Running exit tasks
Terminated
 # Terminating descendant process 12053 /bin/bash usr/sbin/rear -D mkrescue

i.e. the Terminating descendant process 12053 appeasr too late.

jsmeix commented at 2019-03-19 12:53:

Now things work really well for me:

For testing I have at the beginning of init/default/030_update_recovery_system.sh

( LogPrint "First subshell $BASHPID"
  ( LogPrint "Second subshell $BASHPID"
    ( LogPrint "Third subshell $BASHPID"
      ( LogPrint "Fourth subshell $BASHPID"
        pstree -Aplau $MASTER_PID 0<&6 1>&7 2>&8
        Error "Test error a"
        Error "Test error b"
      )
      LogPrint "Code in third subshell after fourth subshell"
      LogPrint "End of third subshell"
    )
    LogPrint "Code in second subshell after third subshell"
    LogPrint "End of second subshell"
  )
  LogPrint "Code in first subshell after second subshell"
  LogPrint "End of first subshell"
)
LogPrint "Message after first subshell"

and then it errors out as follows

# usr/sbin/rear -D mkrescue
Relax-and-Recover 2.4 / Git
Running rear mkrescue (PID 12484)
Using log file: /root/rear.github.master/var/log/rear/rear-g243.log
First subshell 12701
Second subshell 12704
Third subshell 12707
Fourth subshell 12710
rear,12484 usr/sbin/rear -D mkrescue
  `-rear,12701 usr/sbin/rear -D mkrescue
      `-rear,12704 usr/sbin/rear -D mkrescue
          `-rear,12707 usr/sbin/rear -D mkrescue
              `-rear,12710 usr/sbin/rear -D mkrescue
                  `-pstree,12713 -Aplau 12484
ERROR: Test error a
Some latest log messages since the last called script 030_update_recovery_system.sh:
  2019-03-19 13:48:19.778593964 Including init/default/030_update_recovery_system.sh
  2019-03-19 13:48:19.779476109 Entering debugscripts mode via 'set -x'.
  2019-03-19 13:48:19.783102412 First subshell 12701
  2019-03-19 13:48:19.784684687 Second subshell 12704
  2019-03-19 13:48:19.786319435 Third subshell 12707
  2019-03-19 13:48:19.789484642 Fourth subshell 12710
Error exit of rear mkrescue (PID 12484) and its descendant processes
Terminating child process 12701 /bin/bash usr/sbin/rear -D mkrescue
Aborting due to an error, check /root/rear.github.master/var/log/rear/rear-g243.log for details
Exiting rear mkrescue (PID 12484) and its descendant processes ...
Terminating child process 12704 /bin/bash usr/sbin/rear -D mkrescue
Terminating child process 12707 /bin/bash usr/sbin/rear -D mkrescue
Terminating child process 12710 /bin/bash usr/sbin/rear -D mkrescue
Running exit tasks
Terminated

With Error() not from a subshell as in

pstree -Aplau $MASTER_PID 0<&6 1>&7 2>&8
Error "Test error"
LogPrint "Message after Error"

it errors out as follows

# usr/sbin/rear -D mkrescue
Relax-and-Recover 2.4 / Git
Running rear mkrescue (PID 18494)
Using log file: /root/rear.github.master/var/log/rear/rear-g243.log
rear,18494 usr/sbin/rear -D mkrescue
  `-pstree,18711 -Aplau 18494
ERROR: Test error
Some latest log messages since the last called script 030_update_recovery_system.sh:
  2019-03-19 13:50:00.386331767 Including init/default/030_update_recovery_system.sh
  2019-03-19 13:50:00.387170921 Entering debugscripts mode via 'set -x'.
Aborting due to an error, check /root/rear.github.master/var/log/rear/rear-g243.log for details
Exiting rear mkrescue (PID 18494) and its descendant processes ...
Running exit tasks
Terminated

Without any Error it finishes as follows:

# usr/sbin/rear -D mkrescue
Relax-and-Recover 2.4 / Git
Running rear mkrescue (PID 22530)
...
Exiting rear mkrescue (PID 22530) and its descendant processes ...
Running exit tasks
You should also rm -Rf /tmp/rear.i5DoiT2uwBxcDOH

jsmeix commented at 2019-03-19 12:54:

@rear/contributors
if there are no objections I would like to merge it tomorrow.

jsmeix commented at 2019-03-19 16:07:

I must not terminate the current process that runs the Error funtion.

Now with

( LogPrint "First subshell $BASHPID"
  ( LogPrint "Second subshell $BASHPID"
    ( LogPrint "Third subshell $BASHPID"
      ( LogPrint "Fourth subshell $BASHPID"
        pstree -Aplau $MASTER_PID 0<&6 1>&7 2>&8
        Error "Test error a"
        Error "Test error b"
      )
      LogPrint "Code in third subshell after fourth subshell"
      LogPrint "End of third subshell"
    )
    LogPrint "Code in second subshell after third subshell"
    LogPrint "End of second subshell"
  )
  LogPrint "Code in first subshell after second subshell"
  LogPrint "End of first subshell"
)
LogPrint "Message after first subshell"

it errors out as follows

# usr/sbin/rear -D mkrescue
Relax-and-Recover 2.4 / Git
Running rear mkrescue (PID 19692)
Using log file: /root/rear.github.master/var/log/rear/rear-g243.log
First subshell 19909
Second subshell 19912
Third subshell 19915
Fourth subshell 19918
rear,19692 usr/sbin/rear -D mkrescue
  `-rear,19909 usr/sbin/rear -D mkrescue
      `-rear,19912 usr/sbin/rear -D mkrescue
          `-rear,19915 usr/sbin/rear -D mkrescue
              `-rear,19918 usr/sbin/rear -D mkrescue
                  `-pstree,19921 -Aplau 19692
ERROR: Test error a
Some latest log messages since the last called script 030_update_recovery_system.sh:
  2019-03-19 17:02:24.660213376 Including init/default/030_update_recovery_system.sh
  2019-03-19 17:02:24.661045553 Entering debugscripts mode via 'set -x'.
  2019-03-19 17:02:24.664613768 First subshell 19909
  2019-03-19 17:02:24.666223200 Second subshell 19912
  2019-03-19 17:02:24.667872244 Third subshell 19915
  2019-03-19 17:02:24.669971807 Fourth subshell 19918
Error exit of rear mkrescue (PID 19692) and its descendant processes
Terminating child process 19909 /bin/bash usr/sbin/rear -D mkrescue
Aborting due to an error, check /root/rear.github.master/var/log/rear/rear-g243.log for details
Exiting rear mkrescue (PID 19692) and its descendant processes ...
Terminating child process 19912 /bin/bash usr/sbin/rear -D mkrescue
Terminating child process 19915 /bin/bash usr/sbin/rear -D mkrescue
Exiting subshell 4
Running exit tasks
Terminated

Now the current process that runs the Error funtion (here subshell 4 with PID 19918)
gets no longer terminated "from outside" (via SIGTERM)
but exits latest on its own (via Exiting subshell 4).

jsmeix commented at 2019-03-20 15:35:

For the fun of it what I tested right now:
The code

( LogPrint "First subshell $BASHPID"
  ( LogPrint "First background subshell that ignores SIGTERM $BASHPID"
    builtin trap "LogPrint First background subshell got SIGTERM" SIGTERM
    for i in $( seq 5 ) ; do LogPrint "First background subshell $i" ; sleep 1 ; done
    LogPrint "First background subshell done"
  ) &
  ( LogPrint "Second subshell $BASHPID"
    ( LogPrint "Second background subshell that ignores SIGTERM $BASHPID"
      builtin trap "LogPrint Second background subshell got SIGTERM" SIGTERM
      for i in $( seq 5 ) ; do LogPrint "Second background subshell $i" ; sleep 1 ; done
      LogPrint "Second background subshell done"
    ) &
    ( LogPrint "Third subshell $BASHPID"
      ( LogPrint "Third background subshell that ignores SIGTERM $BASHPID"
        builtin trap "LogPrint Third background subshell got SIGTERM" SIGTERM
        for i in $( seq 5 ) ; do LogPrint "Third background subshell $i" ; sleep 1 ; done
        LogPrint "Third background subshell done"
      ) &
      ( LogPrint "Fourth subshell $BASHPID"
        ( LogPrint "Fourth background subshell that ignores SIGTERM $BASHPID"
          builtin trap "LogPrint Fourth background subshell got SIGTERM" SIGTERM
          for i in $( seq 5 ) ; do LogPrint "Fourth background subshell $i" ; sleep 1 ; done
          LogPrint "Fourth background subshell done"
        ) &
        pstree -Aplau $MASTER_PID 0<&6 1>&7 2>&8
        Error "Test error a"
        Error "Test error b"
      )
      LogPrint "Code in third subshell after fourth subshell"
      LogPrint "End of third subshell"
    )
    LogPrint "Code in second subshell after third subshell"
    LogPrint "End of second subshell"
  )
  LogPrint "Code in first subshell after second subshell"
  LogPrint "End of first subshell"
)
LogPrint "Message after first subshell"

errors out as follows

# usr/sbin/rear -D mkrescue
Relax-and-Recover 2.4 / Git
Running rear mkrescue (PID 14326)
Using log file: /root/rear.github.master/var/log/rear/rear-g243.log
First subshell 14543
First background subshell that ignores SIGTERM 14546
Second subshell 14547
Second background subshell that ignores SIGTERM 14553
First background subshell 1
Third subshell 14555
Second background subshell 1
Third background subshell that ignores SIGTERM 14565
Fourth subshell 14567
Fourth background subshell that ignores SIGTERM 14575
Third background subshell 1
Fourth background subshell 1
rear,14326 usr/sbin/rear -D mkrescue
  `-rear,14543 usr/sbin/rear -D mkrescue
      |-rear,14546 usr/sbin/rear -D mkrescue
      |   `-sleep,14564 1
      `-rear,14547 usr/sbin/rear -D mkrescue
          |-rear,14553 usr/sbin/rear -D mkrescue
          |   `-sleep,14573 1
          `-rear,14555 usr/sbin/rear -D mkrescue
              |-rear,14565 usr/sbin/rear -D mkrescue
              `-rear,14567 usr/sbin/rear -D mkrescue
                  |-pstree,14576 -Aplau 14326
                  `-rear,14575 usr/sbin/rear -D mkrescue
ERROR: Test error a
Some latest log messages since the last called script 030_update_recovery_system.sh:
  2019-03-20 16:25:35.895662577 First background subshell 1
  2019-03-20 16:25:35.894978735 Third subshell 14555
  2019-03-20 16:25:35.898088412 Second background subshell 1
  2019-03-20 16:25:35.898284400 Third background subshell that ignores SIGTERM 14565
  2019-03-20 16:25:35.898427918 Fourth subshell 14567
  2019-03-20 16:25:35.900234592 Fourth background subshell that ignores SIGTERM 14575
  2019-03-20 16:25:35.901375014 Third background subshell 1
  2019-03-20 16:25:35.903045800 Fourth background subshell 1
Error exit of rear mkrescue (PID 14326) and its descendant processes
Terminating child process 14543 /bin/bash usr/sbin/rear -D mkrescue
Aborting due to an error, check /root/rear.github.master/var/log/rear/rear-g243.log for details
Exiting rear mkrescue (PID 14326) and its descendant processes ...
Terminating child process 14547 /bin/bash usr/sbin/rear -D mkrescue
Terminating child process 14555 /bin/bash usr/sbin/rear -D mkrescue
Terminating child process 14575 /bin/bash usr/sbin/rear -D mkrescue
Terminating child process 14587 sleep 1
Fourth background subshell got SIGTERM
Fourth background subshell 2
Terminating child process 14565 /bin/bash usr/sbin/rear -D mkrescue
Terminating child process 14584 sleep 1
Third background subshell got SIGTERM
Third background subshell 2
Terminating child process 14553 /bin/bash usr/sbin/rear -D mkrescue
Terminating child process 14573 sleep 1
Second background subshell got SIGTERM
Second background subshell 2
Terminating child process 14546 /bin/bash usr/sbin/rear -D mkrescue
Terminating child process 14564 sleep 1
First background subshell got SIGTERM
First background subshell 2
Fourth background subshell 3
Third background subshell 3
Second background subshell 3
Child process 14575 not yet terminated
First background subshell 3
Child process 14565 not yet terminated
Child process 14553 not yet terminated
Child process 14546 not yet terminated
Killing child process 14575 /bin/bash usr/sbin/rear -D mkrescue
Killing child process 14565 /bin/bash usr/sbin/rear -D mkrescue
Killing child process 14553 /bin/bash usr/sbin/rear -D mkrescue
Killing child process 14546 /bin/bash usr/sbin/rear -D mkrescue
Exiting subshell 4 (where the actual error happened)
Running exit tasks
Terminated

jsmeix commented at 2019-03-20 16:03:

FYI:
When one removes the

        Error "Test error a"
        Error "Test error b"

from the above code and changes
the for i in $( seq 5 ) to for i in $( seq 55 )
to keep the background processes running longer than "rear -D mkrescue" runs,
the background processes are not terminated because when their parents
which are the four subshells finish, init inherits the then orphaned
background processes so that when "rear -D mkrescue" finishes
the pstree -Aplau output looks as follows (excerpts)

systemd,1 --system --deserialize 28
...
  |   ...   |   `-bash,21908
  |   ...   |       `-rear,2876 usr/sbin/rear -D mkrescue
  |   ...   |           `-rear,19197 usr/sbin/rear -D mkrescue
  |   ...   |               `-pstree,19198 -Aplau
...
  |-rear,3135 usr/sbin/rear -D mkrescue
  |   `-sleep,19185 1
  |-rear,3143 usr/sbin/rear -D mkrescue
  |   `-sleep,19186 1
  |-rear,3174 usr/sbin/rear -D mkrescue
  |   `-sleep,19192 1
  |-rear,3216 usr/sbin/rear -D mkrescue
  |   `-sleep,19191 1

which results that the orphaned background processes
continue to run after "rear -D mkrescue" finished
until each orphaned background process ends on its own
which looks like (shortened):

user@host:~/rear.github.master # usr/sbin/rear -D mkrescue
Relax-and-Recover 2.4 / Git
Running rear mkrescue (PID 2876)
Using log file: /root/rear.github.master/var/log/rear/rear-g243.log
First subshell 3132
First background subshell that ignores SIGTERM 3135
Second subshell 3136
Second background subshell that ignores SIGTERM 3143
Third subshell 3150
First background subshell 1
Third background subshell that ignores SIGTERM 3174
Second background subshell 1
Fourth subshell 3175
Fourth background subshell that ignores SIGTERM 3216
Third background subshell 1
Fourth background subshell 1
rear,2876 usr/sbin/rear -D mkrescue
  `-rear,3132 usr/sbin/rear -D mkrescue
      |-rear,3135 usr/sbin/rear -D mkrescue
      |   `-sleep,3206 1
      `-rear,3136 usr/sbin/rear -D mkrescue
          |-rear,3143 usr/sbin/rear -D mkrescue
          |   `-sleep,3217 1
          `-rear,3150 usr/sbin/rear -D mkrescue
              |-rear,3174 usr/sbin/rear -D mkrescue
              `-rear,3175 usr/sbin/rear -D mkrescue
                  |-pstree,3218 -Aplau 2876
                  `-rear,3216 usr/sbin/rear -D mkrescue
Code in third subshell after fourth subshell
End of third subshell
Code in second subshell after third subshell
End of second subshell
Code in first subshell after second subshell
End of first subshell
Message after first subshell
Message after first subshell
Using UEFI Boot Loader for Linux (USING_UEFI_BOOTLOADER=1)
Using autodetected kernel '/boot/vmlinuz-4.12.14-lp150.12.25-default' as kernel in the recovery system
Creating disk layout
First background subshell 2
Second background subshell 2
Third background subshell 2
Fourth background subshell 2
...
Second background subshell 36
First background subshell 36
Third background subshell 36
Fourth background subshell 36
Exiting rear mkrescue (PID 2876) and its descendant processes ...
Second background subshell 37
First background subshell 37
Fourth background subshell 37
Third background subshell 37
Second background subshell 38
First background subshell 38
Fourth background subshell 38
Third background subshell 38
First background subshell 39
Second background subshell 39
Fourth background subshell 39
Third background subshell 39
Running exit tasks
You should also rm -Rf /tmp/rear.sHHbRi39A3v6vhQ
user@host:~/rear.github.master # First background subshell 40
Second background subshell 40
Fourth background subshell 40
Third background subshell 40
...
First background subshell 55
Second background subshell 55
Third background subshell 55
Fourth background subshell 55
First background subshell done
Second background subshell done
Fourth background subshell done
Third background subshell done

jsmeix commented at 2019-03-20 16:08:

I will sleep one more time over it
and if I see no further issues with it
I would like to merge it tomorrow.


[Export of Github issue for rear/rear.]