Darwin builds forking off processes never finish
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 17.7k
- Forks
- 2k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 80
Description
Describe the bug
I have some Nix build forking off a long-running process in the background. In that specific example, a postgresql database.
The build process starts the database, does some insertions and queries in it, then renders a document into $out (end of build script).
On Linux, after all steps in the build script have been finished, the build exits, and the output can be observed.
On Darwin, the build process gets stuck indefinitely.
A workaround is to manually register cleanup traps in bash.
Steps To Reproduce
Build the following on x86_64-linux vs aarch64-darwin:
let
pkgs = import <nixpkgs> { };
in
pkgs.callPackage
(
with import <nixpkgs> { };
{ stdenv, ... }:
stdenv.mkDerivation {
pname = "foo";
version = "1";
buildCommand = ''
sleep infinity &
echo foo > $out
'';
}
)
{ }
Expected behavior
I'd expect in both cases the build to end, and the sleep process to be killed at the end of the build script.
nix-env --version output
nix-env (Nix) 2.13.3
Priorities
Add 👍 to issues you find important.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided derivation on x86_64-linux and aarch64-darwin, then trace the platform-specific build-process cleanup behavior. Compare how the background sleep process is handled on each platform; done means the Darwin build exits and the background process is terminated without manual cleanup traps.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bash, cpp, macos
- Domain
- build-system, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100