[systemd-devel] [PATCHv3] core: send sigabrt on watchdog timeout to get the stacktrace

2014-10-28 Thread Umut Tezduyar Lindskog
if sigabrt doesn't do the job, follow regular shutdown
routine, sigterm  sigkill.
---
 TODO|  2 --
 man/systemd.service.xml |  5 +++--
 src/core/busname.c  |  2 +-
 src/core/mount.c|  3 ++-
 src/core/scope.c|  2 +-
 src/core/service.c  | 37 ++---
 src/core/service.h  |  1 +
 src/core/socket.c   |  3 ++-
 src/core/swap.c |  3 ++-
 src/core/unit.c | 24 ++--
 src/core/unit.h |  8 +++-
 11 files changed, 63 insertions(+), 27 deletions(-)

diff --git a/TODO b/TODO
index acac4e3..3e85eee 100644
--- a/TODO
+++ b/TODO
@@ -54,8 +54,6 @@ Features:
 
 * consider showing the unit names during boot up in the status output, not 
just the unit descriptions
 
-* send SIGABRT when a service watchdog is triggered, by default, so that we 
acquire a backtrace of the hang.
-
 * dhcp: do we allow configuring dhcp routes on interfaces that are not the one 
we got the dhcp info from?
 
 * maybe allow timer units with an empty Units= setting, so that they
diff --git a/man/systemd.service.xml b/man/systemd.service.xml
index 115d169..e563b19 100644
--- a/man/systemd.service.xml
+++ b/man/systemd.service.xml
@@ -593,8 +593,9 @@
 (i.e. the keep-alive ping). If the time
 between two such calls is larger than
 the configured time, then the service
-is placed in a failed state. By
-setting varnameRestart=/varname to
+is placed in a failed state and it will
+be terminated with varnameSIGABRT/varname.
+By setting varnameRestart=/varname to
 optionon-failure/option or
 optionalways/option, the service
 will be automatically restarted. The
diff --git a/src/core/busname.c b/src/core/busname.c
index 22d2a6d..68cb6ca 100644
--- a/src/core/busname.c
+++ b/src/core/busname.c
@@ -446,7 +446,7 @@ static void busname_enter_signal(BusName *n, BusNameState 
state, BusNameResult f
 
 r = unit_kill_context(UNIT(n),
   kill_context,
-  state != BUSNAME_SIGTERM,
+  state != BUSNAME_SIGTERM ? KILL_KILL : 
KILL_TERMINATE,
   -1,
   n-control_pid,
   false);
diff --git a/src/core/mount.c b/src/core/mount.c
index e284357..01243c3 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -775,7 +775,8 @@ static void mount_enter_signal(Mount *m, MountState state, 
MountResult f) {
 r = unit_kill_context(
 UNIT(m),
 m-kill_context,
-state != MOUNT_MOUNTING_SIGTERM  state != 
MOUNT_UNMOUNTING_SIGTERM  state != MOUNT_REMOUNTING_SIGTERM,
+(state != MOUNT_MOUNTING_SIGTERM  state != 
MOUNT_UNMOUNTING_SIGTERM  state != MOUNT_REMOUNTING_SIGTERM) ?
+KILL_KILL : KILL_TERMINATE,
 -1,
 m-control_pid,
 false);
diff --git a/src/core/scope.c b/src/core/scope.c
index e8f9e8d..0f7c1f9 100644
--- a/src/core/scope.c
+++ b/src/core/scope.c
@@ -243,7 +243,7 @@ static void scope_enter_signal(Scope *s, ScopeState state, 
ScopeResult f) {
 r = unit_kill_context(
 UNIT(s),
 s-kill_context,
-state != SCOPE_STOP_SIGTERM,
+state != SCOPE_STOP_SIGTERM ? KILL_KILL : 
KILL_TERMINATE,
 -1, -1, false);
 if (r  0)
 goto fail;
diff --git a/src/core/service.c b/src/core/service.c
index d160c4e..2b16778 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -56,6 +56,7 @@ static const UnitActiveState 
state_translation_table[_SERVICE_STATE_MAX] = {
 [SERVICE_EXITED] = UNIT_ACTIVE,
 [SERVICE_RELOAD] = UNIT_RELOADING,
 [SERVICE_STOP] = UNIT_DEACTIVATING,
+[SERVICE_STOP_SIGABRT] = UNIT_DEACTIVATING,
 [SERVICE_STOP_SIGTERM] = UNIT_DEACTIVATING,
 [SERVICE_STOP_SIGKILL] = UNIT_DEACTIVATING,
 [SERVICE_STOP_POST] = UNIT_DEACTIVATING,
@@ -76,6 +77,7 @@ static const UnitActiveState 
state_translation_table_idle[_SERVICE_STATE_MAX] =
 [SERVICE_EXITED] = UNIT_ACTIVE,
 [SERVICE_RELOAD] = UNIT_RELOADING,
 [SERVICE_STOP] = UNIT_DEACTIVATING,
+[SERVICE_STOP_SIGABRT] = UNIT_DEACTIVATING,
 [SERVICE_STOP_SIGTERM] = UNIT_DEACTIVATING,
 [SERVICE_STOP_SIGKILL] = UNIT_DEACTIVATING,
 [SERVICE_STOP_POST] = UNIT_DEACTIVATING,
@@ -663,7 +665,7 @@ static 

Re: [systemd-devel] [PATCHv3] core: send sigabrt on watchdog timeout to get the stacktrace

2014-10-28 Thread Lennart Poettering
On Tue, 28.10.14 16:35, Umut Tezduyar Lindskog (umut.tezdu...@axis.com) wrote:

Applied! Thanks!

 if sigabrt doesn't do the job, follow regular shutdown
 routine, sigterm  sigkill.
 ---
  TODO|  2 --
  man/systemd.service.xml |  5 +++--
  src/core/busname.c  |  2 +-
  src/core/mount.c|  3 ++-
  src/core/scope.c|  2 +-
  src/core/service.c  | 37 ++---
  src/core/service.h  |  1 +
  src/core/socket.c   |  3 ++-
  src/core/swap.c |  3 ++-
  src/core/unit.c | 24 ++--
  src/core/unit.h |  8 +++-
  11 files changed, 63 insertions(+), 27 deletions(-)
 
 diff --git a/TODO b/TODO
 index acac4e3..3e85eee 100644
 --- a/TODO
 +++ b/TODO
 @@ -54,8 +54,6 @@ Features:
  
  * consider showing the unit names during boot up in the status output, not 
 just the unit descriptions
  
 -* send SIGABRT when a service watchdog is triggered, by default, so that we 
 acquire a backtrace of the hang.
 -
  * dhcp: do we allow configuring dhcp routes on interfaces that are not the 
 one we got the dhcp info from?
  
  * maybe allow timer units with an empty Units= setting, so that they
 diff --git a/man/systemd.service.xml b/man/systemd.service.xml
 index 115d169..e563b19 100644
 --- a/man/systemd.service.xml
 +++ b/man/systemd.service.xml
 @@ -593,8 +593,9 @@
  (i.e. the keep-alive ping). If the time
  between two such calls is larger than
  the configured time, then the service
 -is placed in a failed state. By
 -setting varnameRestart=/varname to
 +is placed in a failed state and it will
 +be terminated with 
 varnameSIGABRT/varname.
 +By setting varnameRestart=/varname to
  optionon-failure/option or
  optionalways/option, the service
  will be automatically restarted. The
 diff --git a/src/core/busname.c b/src/core/busname.c
 index 22d2a6d..68cb6ca 100644
 --- a/src/core/busname.c
 +++ b/src/core/busname.c
 @@ -446,7 +446,7 @@ static void busname_enter_signal(BusName *n, BusNameState 
 state, BusNameResult f
  
  r = unit_kill_context(UNIT(n),
kill_context,
 -  state != BUSNAME_SIGTERM,
 +  state != BUSNAME_SIGTERM ? KILL_KILL : 
 KILL_TERMINATE,
-1,
n-control_pid,
false);
 diff --git a/src/core/mount.c b/src/core/mount.c
 index e284357..01243c3 100644
 --- a/src/core/mount.c
 +++ b/src/core/mount.c
 @@ -775,7 +775,8 @@ static void mount_enter_signal(Mount *m, MountState 
 state, MountResult f) {
  r = unit_kill_context(
  UNIT(m),
  m-kill_context,
 -state != MOUNT_MOUNTING_SIGTERM  state != 
 MOUNT_UNMOUNTING_SIGTERM  state != MOUNT_REMOUNTING_SIGTERM,
 +(state != MOUNT_MOUNTING_SIGTERM  state != 
 MOUNT_UNMOUNTING_SIGTERM  state != MOUNT_REMOUNTING_SIGTERM) ?
 +KILL_KILL : KILL_TERMINATE,
  -1,
  m-control_pid,
  false);
 diff --git a/src/core/scope.c b/src/core/scope.c
 index e8f9e8d..0f7c1f9 100644
 --- a/src/core/scope.c
 +++ b/src/core/scope.c
 @@ -243,7 +243,7 @@ static void scope_enter_signal(Scope *s, ScopeState 
 state, ScopeResult f) {
  r = unit_kill_context(
  UNIT(s),
  s-kill_context,
 -state != SCOPE_STOP_SIGTERM,
 +state != SCOPE_STOP_SIGTERM ? KILL_KILL : 
 KILL_TERMINATE,
  -1, -1, false);
  if (r  0)
  goto fail;
 diff --git a/src/core/service.c b/src/core/service.c
 index d160c4e..2b16778 100644
 --- a/src/core/service.c
 +++ b/src/core/service.c
 @@ -56,6 +56,7 @@ static const UnitActiveState 
 state_translation_table[_SERVICE_STATE_MAX] = {
  [SERVICE_EXITED] = UNIT_ACTIVE,
  [SERVICE_RELOAD] = UNIT_RELOADING,
  [SERVICE_STOP] = UNIT_DEACTIVATING,
 +[SERVICE_STOP_SIGABRT] = UNIT_DEACTIVATING,
  [SERVICE_STOP_SIGTERM] = UNIT_DEACTIVATING,
  [SERVICE_STOP_SIGKILL] = UNIT_DEACTIVATING,
  [SERVICE_STOP_POST] = UNIT_DEACTIVATING,
 @@ -76,6 +77,7 @@ static const UnitActiveState 
 state_translation_table_idle[_SERVICE_STATE_MAX] =
  [SERVICE_EXITED] = UNIT_ACTIVE,
  [SERVICE_RELOAD] = UNIT_RELOADING,
  [SERVICE_STOP] = UNIT_DEACTIVATING,
 +