Skip to content

Background processes in scripts are not terminated #4102

@ValdikSS

Description

@ValdikSS

mkosi commit the issue has been seen with

25.3, 26

Used host distribution

Fedora 43, Arch Linux

Used target distribution

Debian 13

Linux kernel version used

6.17.12-300.fc43.x86_64

CPU architectures issue was seen on

x86_64

Unexpected behaviour you saw

If build or postinst script run any process in the background, mkosi does not terminate these processes upon exiting the script/sandbox/image building process.

Applies to both regular host scripts and .chroot scripts.

Used mkosi config

# cat <<EOF >mkosi.postinst
#!/bin/bash
sleep 600 &
exit 0
EOF

# chmod +x mkosi.postinst

# mkosi -d debian -r trixie -t directory

mkosi output

# mkosi -d debian -r trixie -t directory

‣ Validating certificates and keys
‣ Syncing package manager metadata
…
‣ Building main image
‣  Installing Debian
…
‣  Running postinstall script /root/b/mkosi.postinst…
‣  Generating system users
‣  Generating volatile files
‣  Applying presets…
‣  Generating hardware database
No hwdb files found, skipping.
‣  /root/b/image size is 103.0M.


mkosi finished here.

On the host:
# ps aux
root        2904  0.0  0.0   3260  2172 pts/0    S    23:25   0:00 sleep 600

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions