Skip to content

Service is active (running) after main process has exited #28030

Closed

Description

@ElvishJerricco

systemd version the issue has been seen with

253.5

Used distribution

NixOS 23.05

Linux kernel version used

6.1.33

CPU architectures issue was seen on

x86_64

Component

systemd

Expected behaviour you didn't see

A service unit with Type=simple and ExitType=main should not be considered active (running) after the main process has exited.

Unexpected behaviour you saw

The service unit is still active (running) after the main process has exited.

Steps to reproduce the problem

Start this service:

[Service]
Type=simple
ExitType=main
ExecStart=/usr/bin/bash -c "/usr/bin/systemctl --version; /usr/bin/sleep infinity &"

It should immediately become inactive (dead), as the main bash process exits immediately. Instead, it's active (running).

I've bisected this issue down to this commit: ae83e97, which is the backport of this PR: #27735

Additional program output to the terminal or log subsystem illustrating the issue

● show-bug.service
     Loaded: loaded (/etc/systemd/system/show-bug.service; enabled; preset: enabled)
     Active: active (running) since Wed 2023-06-14 00:58:36 UTC; 3s ago
    Process: 702 ExecStart=/usr/bin/bash -c /usr/bin/systemctl --version; /usr/bin/sleep infinity & (code=exited, status=0/SUCCESS)
   Main PID: 702 (code=exited, status=0/SUCCESS)
         IP: 0B in, 0B out
         IO: 0B read, 0B written
      Tasks: 1 (limit: 1150)
     Memory: 404.0K
        CPU: 4ms
     CGroup: /system.slice/show-bug.service
             └─717 /usr/bin/sleep infinity

Jun 14 00:58:36 machine systemd[1]: Started show-bug.service.
Jun 14 00:58:36 machine bash[703]: systemd 253 (253.5)
Jun 14 00:58:36 machine bash[703]: +PAM +AUDIT -SELINUX +APPARMOR +IMA +SMACK +SECCOMP +GCRYPT -GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN +IPTC +KMOD +LIBCRYPTSETUP +LIBFDISK +PCRE2 -PWQUALITY +P11KIT -QRENCODE +TPM2 +BZIP2 +LZ4 +XZ +ZLIB +ZSTD +BPF_FRAMEWORK -XKBCOMMON +UTMP -SYSVINIT default-hierarchy=unified

Activity

  1. Toolybird commented on Jun 14, 2023

    @Toolybird

    Essentially the same issue as #27953

  2. msekletar commented on Jun 14, 2023

    @msekletar
    Contributor

    Hi @ElvishJerricco I've posted fix for #27953 (which I think is duplicate of this one) as PR #28035. Testing that PR would be much appreciated.

  3. added this to the v254 milestone on Jun 14, 2023
  4. ElvishJerricco commented on Jun 19, 2023

    @ElvishJerricco
    ContributorAuthor

    Closed by #28000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛Programming errors, that need preferential fixingpid1

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions