<div class="highlight highlight-text-shell-session notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="➜ deno install --allow-net --allow-read https://deno.land/std@0.92.0/http/file_server.ts
Download https://deno.land/std@0.92.0/http/file_server.ts
Download https://deno.land/std@0.92.0/path/mod.ts
Download https://deno.land/std@0.92.0/flags/mod.ts
Download https://deno.land/std@0.92.0/_util/assert.ts
Download https://deno.land/std@0.92.0/http/server.ts
Download https://deno.land/std@0.92.0/async/mod.ts
Download https://deno.land/std@0.92.0/http/_io.ts
Download https://deno.land/std@0.92.0/io/bufio.ts
Download https://deno.land/std@0.92.0/path/posix.ts
Download https://deno.land/std@0.92.0/path/common.ts
Download https://deno.land/std@0.92.0/path/glob.ts
Download https://deno.land/std@0.92.0/path/separator.ts
Download https://deno.land/std@0.92.0/path/win32.ts
Download https://deno.land/std@0.92.0/_util/os.ts
Download https://deno.land/std@0.92.0/path/_interface.ts
Download https://deno.land/std@0.92.0/path/_constants.ts
Download https://deno.land/std@0.92.0/path/_util.ts
Download https://deno.land/std@0.92.0/textproto/mod.ts
Download https://deno.land/std@0.92.0/http/http_status.ts
Download https://deno.land/std@0.92.0/async/deferred.ts
Download https://deno.land/std@0.92.0/async/delay.ts
Download https://deno.land/std@0.92.0/async/pool.ts
Download https://deno.land/std@0.92.0/async/mux_async_iterator.ts
Download https://deno.land/std@0.92.0/io/buffer.ts
Download https://deno.land/std@0.92.0/bytes/mod.ts
Download https://deno.land/std@0.92.0/io/util.ts
Check https://deno.land/std@0.92.0/http/file_server.ts
✅ Successfully installed file_server
C:\Users\felip\.deno\bin\file_server.cmd
C:\Users\felip\.deno\bin\file_server (shell)
ℹ️  Add C:\Users\felip\.deno\bin to PATH
    set PATH=%PATH%;C:\Users\felip\.deno\bin
➜ C:\Users\felip\.deno\bin\file_server.cmd
HTTP server listening on http://0.0.0.0:4507/
^CTerminate batch job (Y/N)?"><pre class="notranslate">➜ <span class="pl-s1">deno install --allow-net --allow-read https://deno.land/std@0.92.0/http/file_server.ts</span>
<span class="pl-c1">Download https://deno.land/std@0.92.0/http/file_server.ts</span>
<span class="pl-c1">Download https://deno.land/std@0.92.0/path/mod.ts</span>
<span class="pl-c1">Download https://deno.land/std@0.92.0/flags/mod.ts</span>
<span class="pl-c1">Download https://deno.land/std@0.92.0/_util/assert.ts</span>
<span class="pl-c1">Download https://deno.land/std@0.92.0/http/server.ts</span>
<span class="pl-c1">Download https://deno.land/std@0.92.0/async/mod.ts</span>
<span class="pl-c1">Download https://deno.land/std@0.92.0/http/_io.ts</span>
<span class="pl-c1">Download https://deno.land/std@0.92.0/io/bufio.ts</span>
<span class="pl-c1">Download https://deno.land/std@0.92.0/path/posix.ts</span>
<span class="pl-c1">Download https://deno.land/std@0.92.0/path/common.ts</span>
<span class="pl-c1">Download https://deno.land/std@0.92.0/path/glob.ts</span>
<span class="pl-c1">Download https://deno.land/std@0.92.0/path/separator.ts</span>
<span class="pl-c1">Download https://deno.land/std@0.92.0/path/win32.ts</span>
<span class="pl-c1">Download https://deno.land/std@0.92.0/_util/os.ts</span>
<span class="pl-c1">Download https://deno.land/std@0.92.0/path/_interface.ts</span>
<span class="pl-c1">Download https://deno.land/std@0.92.0/path/_constants.ts</span>
<span class="pl-c1">Download https://deno.land/std@0.92.0/path/_util.ts</span>
<span class="pl-c1">Download https://deno.land/std@0.92.0/textproto/mod.ts</span>
<span class="pl-c1">Download https://deno.land/std@0.92.0/http/http_status.ts</span>
<span class="pl-c1">Download https://deno.land/std@0.92.0/async/deferred.ts</span>
<span class="pl-c1">Download https://deno.land/std@0.92.0/async/delay.ts</span>
<span class="pl-c1">Download https://deno.land/std@0.92.0/async/pool.ts</span>
<span class="pl-c1">Download https://deno.land/std@0.92.0/async/mux_async_iterator.ts</span>
<span class="pl-c1">Download https://deno.land/std@0.92.0/io/buffer.ts</span>
<span class="pl-c1">Download https://deno.land/std@0.92.0/bytes/mod.ts</span>
<span class="pl-c1">Download https://deno.land/std@0.92.0/io/util.ts</span>
<span class="pl-c1">Check https://deno.land/std@0.92.0/http/file_server.ts</span>
<span class="pl-c1">✅ Successfully installed file_server</span>
<span class="pl-c1">C:\Users\felip\.deno\bin\file_server.cmd</span>
<span class="pl-c1">C:\Users\felip\.deno\bin\file_server (shell)</span>
<span class="pl-c1">ℹ️  Add C:\Users\felip\.deno\bin to PATH</span>
<span class="pl-c1">    set PATH=%PATH%;C:\Users\felip\.deno\bin</span>
➜ <span class="pl-s1">C:<span class="pl-cce">\U</span>sers<span class="pl-cce">\f</span>elip<span class="pl-cce">\.</span>deno<span class="pl-cce">\b</span>in<span class="pl-cce">\f</span>ile_server.cmd</span>
<span class="pl-c1">HTTP server listening on http://0.0.0.0:4507/</span>
<span class="pl-c1">^CTerminate batch job (Y/N)?</span></pre></div>
<p dir="auto">As can be seen, <code class="notranslate">cmd.exe</code> handles the <code class="notranslate">Ctrl</code>+<code class="notranslate">C</code> event instead of the deno process.</p>
<p dir="auto">Currently, all the available signal handling API throw "unimplemented" errors for Windows platforms.</p>
<p dir="auto">It would be great to have cross-platform signal handling along the lines of <a href="https://nodejs.org/api/process.html#process_signal_events" rel="nofollow">NodeJS Process Signal Events</a>...</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// ...works in NodeJS...

[`SIGBREAK`, `SIGINT`, `SIGUSR1`, `SIGUSR2`, `uncaughtException`, `SIGTERM`].forEach((eventType) =&gt; {
	process.on(eventType, catchSignal.bind(null, eventType));
});
[`exit`].forEach((eventType) =&gt; {
	process.on(eventType, catchExit.bind(null, eventType));
});

function catchSignal(eventType) {
	console.log('Caught signal...', { eventType });
}
function catchExit(eventType) {
	console.log('Now exiting...', { eventType });
}

setTimeout(() =&gt; {
	console.log('The service is now finished.');
}, 2000);"><pre class="notranslate"><span class="pl-c">// ...works in NodeJS...</span>

<span class="pl-kos">[</span><span class="pl-s">`SIGBREAK`</span><span class="pl-kos">,</span> <span class="pl-s">`SIGINT`</span><span class="pl-kos">,</span> <span class="pl-s">`SIGUSR1`</span><span class="pl-kos">,</span> <span class="pl-s">`SIGUSR2`</span><span class="pl-kos">,</span> <span class="pl-s">`uncaughtException`</span><span class="pl-kos">,</span> <span class="pl-s">`SIGTERM`</span><span class="pl-kos">]</span><span class="pl-kos">.</span><span class="pl-en">forEach</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-s1">eventType</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
	<span class="pl-s1">process</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-s1">eventType</span><span class="pl-kos">,</span> <span class="pl-s1">catchSignal</span><span class="pl-kos">.</span><span class="pl-en">bind</span><span class="pl-kos">(</span><span class="pl-c1">null</span><span class="pl-kos">,</span> <span class="pl-s1">eventType</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">[</span><span class="pl-s">`exit`</span><span class="pl-kos">]</span><span class="pl-kos">.</span><span class="pl-en">forEach</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-s1">eventType</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
	<span class="pl-s1">process</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-s1">eventType</span><span class="pl-kos">,</span> <span class="pl-s1">catchExit</span><span class="pl-kos">.</span><span class="pl-en">bind</span><span class="pl-kos">(</span><span class="pl-c1">null</span><span class="pl-kos">,</span> <span class="pl-s1">eventType</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-k">function</span> <span class="pl-en">catchSignal</span><span class="pl-kos">(</span><span class="pl-s1">eventType</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
	<span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">'Caught signal...'</span><span class="pl-kos">,</span> <span class="pl-kos">{</span> eventType <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>
<span class="pl-k">function</span> <span class="pl-en">catchExit</span><span class="pl-kos">(</span><span class="pl-s1">eventType</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
	<span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">'Now exiting...'</span><span class="pl-kos">,</span> <span class="pl-kos">{</span> eventType <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-en">setTimeout</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
	<span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">'The service is now finished.'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span><span class="pl-kos">,</span> <span class="pl-c1">2000</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>