<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Process Management on Margrop Blog</title>
		<link>https://blog.margrop.net/en/tag/process-management/</link>
		<description>Recent content in Process Management on Margrop Blog</description>
		<generator>Hugo</generator>
		<language>en-US</language>
		
		
		
		
			<lastBuildDate>Mon, 01 Jun 2026 07:00:00 +0800</lastBuildDate>
		
			<atom:link href="https://blog.margrop.net/en/tag/process-management/index.xml" rel="self" type="application/rss+xml" />
			<item>
				<title>Your Background Process Keeps Dying After Shell Exit? Stop Blaming nohup — Understand setsid and Unix Process Lifecycle</title>
				<link>https://blog.margrop.net/en/post/setsid-daemon-process-survival/</link>
				<pubDate>Mon, 01 Jun 2026 07:00:00 +0800</pubDate>
				<guid>https://blog.margrop.net/en/post/setsid-daemon-process-survival/</guid>
				<description>&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;The short version&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;You launched a background service. You used &lt;code&gt;nohup&lt;/code&gt;. You added &lt;code&gt;&amp;amp;&lt;/code&gt;. You redirected output. Everything looked fine. But when you closed the terminal, disconnected SSH, or—more insidiously—when an automation tool finished executing its script, the process silently vanished. You checked &lt;code&gt;ps&lt;/code&gt;—nothing. You checked the port—nothing. No error in the logs. If this has happened to you, you&amp;rsquo;re not alone.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;The root cause isn&amp;rsquo;t SIGHUP—at least, not entirely. The real issue is process group and session membership.&lt;/strong&gt; &lt;code&gt;nohup&lt;/code&gt; merely tells the process to ignore the SIGHUP signal, but the process still belongs to the same session and process group as the parent shell. When the shell exits and sends SIGHUP to the entire process group, &lt;code&gt;nohup&lt;/code&gt; helps—but only if the signal delivery chain stops there. If the controlling terminal is destroyed, if stdin/stdout pipes break, or if the parent&amp;rsquo;s process group is collectively reaped, the process can still die. The proper fix is &lt;code&gt;setsid&lt;/code&gt;: it creates a brand-new session, detaches from the controlling terminal, and places the process in its own process group—so SIGHUP from the parent shell never reaches it in the first place.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This post is based on a real debugging session of the CLIProxyAPI service. The service was started with &lt;code&gt;nohup&lt;/code&gt; but kept disappearing every time an automation script finished. The management panel kept showing &amp;ldquo;connection failed.&amp;rdquo; The culprit turned out to be a subtle Unix process lifecycle issue. This class of problem is common in cloud dev machines, CI runners, SSH jump hosts, and containerized workflows, but it&amp;rsquo;s often misdiagnosed because the underlying process model is poorly understood.&lt;/p&gt;&#xA;&lt;p&gt;All private details have been removed. No real internal addresses, tokens, or paths appear in this article.&lt;/p&gt;</description>
			</item>
	</channel>
</rss>
