From: Charles McGarvey Date: Sun, 17 Jun 2018 21:58:06 +0000 (-0600) Subject: add SIGPIPE slides X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=309c1da6df9319b3bcd760fd3073bafeda9faf09;p=chaz%2Ftalk-event-driven-programming-in-perl add SIGPIPE slides --- diff --git a/css/slides.css b/css/slides.css index abeeb12..e32cb10 100644 --- a/css/slides.css +++ b/css/slides.css @@ -60,3 +60,11 @@ font-size: 38px; } +.sigpipe ul { + font-size: 34px; +} +.ex-sigpipe .perl { + font-size: 38px; +} + + diff --git a/notes.txt b/notes.txt index 0d32c72..6b732a6 100644 --- a/notes.txt +++ b/notes.txt @@ -27,10 +27,10 @@ X kernel facilities (poll, select, etc.) - Mojo::IOLoop 6. Special considerations -- Exceptions in event-driven code. -- SIGPIPE, EPIPE - might have more to do with long-lived processes rather than +X Exceptions in event-driven code. +X SIGPIPE, EPIPE - might have more to do with long-lived processes rather than just event-driven programming, but still something to watch out for... -- You should almost always check the return code of your syscalls to see if they succeeded or not. +X You should almost always check the return code of your syscalls to see if they succeeded or not. 7. Promises: - Future diff --git a/slides.html b/slides.html index 6d589b4..51f9101 100644 --- a/slides.html +++ b/slides.html @@ -498,6 +498,39 @@ $promise->on_fail(sub { ... }); --- class: center, middle +## `SIGPIPE` + +--- +class: sigpipe +## `SIGPIPE` + +- Sent to your program when it writes to a pipe that was closed. + +-- +- Default signal handler terminates the program. + +--- +class: ex-sigpipe + +## Solution: Ignore `SIGPIPE` + +```perl +$SIG{PIPE} = 'IGNORE'; +``` + +??? +Some event loops do this for you. + +-- +.big[ +Look for `EPIPE` from syscalls (like [`write`](http://man.he.net/man2/write)) instead. + +(You *are* checking return codes from your system calls... right?) +] + +--- +class: center, middle + ## Use [`Future::AsyncAwait`](https://metacpan.org/pod/Future::AsyncAwait). ???