git-watchtower 2.3.17 → 2.3.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "git-watchtower",
3
- "version": "2.3.17",
3
+ "version": "2.3.18",
4
4
  "description": "Terminal-based Git branch monitor with activity sparklines and optional dev server with live reload",
5
5
  "main": "bin/git-watchtower.js",
6
6
  "bin": {
@@ -108,6 +108,24 @@ function ensureDir() {
108
108
 
109
109
  /**
110
110
  * Check if a process with the given PID is alive.
111
+ *
112
+ * `process.kill(pid, 0)` is the standard "is this PID alive?" probe. It
113
+ * sends signal 0 (no-op) and surfaces the kernel's answer via errno:
114
+ *
115
+ * - resolves cleanly → process exists and we can signal it
116
+ * - throws ESRCH → no such process; safe to call dead
117
+ * - throws EPERM → process exists but is owned by another
118
+ * user or in a different cgroup. STILL
119
+ * alive — we just can't signal it.
120
+ *
121
+ * Treating EPERM as "dead" was a real bug for the coordinator lock: if
122
+ * a coordinator's PID was reused by another local user's process after
123
+ * a crash, a peer instance would read the lock, see EPERM, decide the
124
+ * coordinator was dead, unlink the lock, and try to take over while
125
+ * the original (or reused) PID was still running. Mirroring the same
126
+ * EPERM-aware check used by src/utils/monitor-lock.js prevents that
127
+ * cleanup-then-clobber race.
128
+ *
111
129
  * @param {number} pid
112
130
  * @returns {boolean}
113
131
  */
@@ -116,7 +134,8 @@ function isProcessAlive(pid) {
116
134
  process.kill(pid, 0);
117
135
  return true;
118
136
  } catch (e) {
119
- return false;
137
+ // ESRCH = no such process; EPERM = exists but owned by another user.
138
+ return e.code === 'EPERM';
120
139
  }
121
140
  }
122
141