@@ -88,3 +88,41 @@ status code rather than reporting the signal properly. This
88
88
module tries to do the right thing, but on Windows systems, you
89
89
may see that incorrect result. There is as far as I'm aware no
90
90
workaround for this.
91
+
92
+ ## util: ` foreground-child/proxy-signals `
93
+
94
+ If you just want to proxy the signals to a child process that the
95
+ main process receives, you can use the ` proxy-signals ` export
96
+ from this package.
97
+
98
+ ``` js
99
+ import { proxySignals } from ' foreground-child/proxy-signals'
100
+
101
+ const childProcess = spawn (' command' , [' some' , ' args' ])
102
+ proxySignals (childProcess)
103
+ ```
104
+
105
+ Now, any fatal signal received by the current process will be
106
+ proxied to the child process.
107
+
108
+ It doesn't go in the other direction; ie, signals sent to the
109
+ child process will not affect the parent. For that, listen to the
110
+ child ` exit ` or ` close ` events, and handle them appropriately.
111
+
112
+ ## util: ` foreground-child/watchdog `
113
+
114
+ If you are spawning a child process, and want to ensure that it
115
+ isn't left dangling if the parent process exits, you can use the
116
+ watchdog utility exported by this module.
117
+
118
+ ``` js
119
+ import { watchdog } from ' foreground-child/watchdog'
120
+
121
+ const childProcess = spawn (' command' , [' some' , ' args' ])
122
+ const watchdogProcess = watchdog (childProcess)
123
+
124
+ // watchdogProcess is a reference to the process monitoring the
125
+ // parent and child. There's usually no reason to do anything
126
+ // with it, as it's silent and will terminate
127
+ // automatically when it's no longer needed.
128
+ ```
0 commit comments