micromamba run resets inherited SIGHUP ignore, breaking outer nohup
Troubleshooting docs
- My problem is not solved in the Troubleshooting docs
Anaconda default channels
- I do NOT use the Anaconda default channels (pkgs/* etc.)
How did you install Mamba?
Micromamba
Search tried in issue tracker
nohup, SIGHUP; also checked daandemeyer/reproc
Latest version of Mamba
- My problem is not solved with the latest version
Tried in Conda?
I do not have this problem with Conda, just with Mamba
Describe your issue
Running a command through nohup micromamba run ... loses the inherited SIGHUP-ignore disposition. The child starts with SIGHUP set to SIG_DFL and terminates when it receives SIGHUP.
Running the same Python executable directly under nohup preserves SIG_IGN. Adding nohup inside micromamba run also preserves it.
Environment
- Micromamba 2.9.0
- Ubuntu 20.04.6 LTS, x86_64
- Linux kernel 5.15.0-1073-azure
- Python 3.11.16
Minimal reproduction
Use Bash and set ENV_PREFIX to an existing micromamba environment containing Python. No application packages are needed.
The probe sends SIGHUP only to itself, so no SSH disconnect or signaling of other processes is necessary.
ENV_PREFIX="/absolute/path/to/existing/environment"
probe='import os,signal; print("SIGHUP=" + signal.getsignal(signal.SIGHUP).name, flush=True); os.kill(os.getpid(), signal.SIGHUP); print("survived", flush=True)'
set +e
# Control: direct Python
nohup "$ENV_PREFIX/bin/python" -c "$probe" \
> /tmp/nohup-direct.log 2>&1 </dev/null
status=$?
cat /tmp/nohup-direct.log
echo "exit=$status"
# Fails: outer nohup only
nohup micromamba run -p "$ENV_PREFIX" python -c "$probe" \
> /tmp/nohup-outer.log 2>&1 </dev/null
status=$?
cat /tmp/nohup-outer.log
echo "exit=$status"
# Workaround: nohup inside micromamba run
nohup micromamba run -p "$ENV_PREFIX" nohup python -c "$probe" \
> /tmp/nohup-inner.log 2>&1 </dev/null
status=$?
cat /tmp/nohup-inner.log
echo "exit=$status"Actual results
Direct Python:
SIGHUP=SIG_IGN
survived
exit=0Outer nohup with micromamba run:
SIGHUP=SIG_DFL
exit=129Outer and inner nohup:
SIGHUP=SIG_IGN
survived
exit=0Expected behavior
An inherited SIGHUP-ignore disposition should remain ignored when launching the command, consistent with normal fork/exec inheritance and the behavior of nohup.
Impact
We encountered this when launching a long-running application from an SSH terminal. Despite starting the launcher with nohup, disconnecting SSH stopped the application. Adding nohup directly before Python inside micromamba run allowed it to survive the same disconnect test.
Source investigation
Micromamba 2.9.0 launches the command through reproc::process::start:
https://github.com/mamba-org/mamba/blob/2.9.0/libmamba/src/core/run.cpp#L457-L459
Reproc v14.2.5 explicitly resets child signal dispositions to SIG_DFL for signals below 32, which includes SIGHUP:
https://github.com/daandemeyer/reproc/blob/v14.2.5/reproc/src/process.posix.c#L217-L237
That reset appears consistent with the observed behavior. I have not independently verified the exact reproc revision linked into my micromamba binary.
Linux documents that ignored signal dispositions normally survive exec:
https://man7.org/linux/man-pages/man7/signal.7.html
Could micromamba preserve inherited ignored signals, particularly SIGHUP, or coordinate a fix with reproc? If the behavior is intentional, documenting this limitation and the inner-nohup workaround would help.
mamba info / micromamba info
Logs
environment.yml
~/.condarc
Source: mamba-org/mamba