Skip to content

Instantly share code, notes, and snippets.

@jdarcy
Created August 18, 2016 01:42
Show Gist options
  • Save jdarcy/ac65ab1121ff8efcf7a4f99cbc80fa92 to your computer and use it in GitHub Desktop.
Save jdarcy/ac65ab1121ff8efcf7a4f99cbc80fa92 to your computer and use it in GitHub Desktop.
Go home, bash. You're drunk.
#!/bin/bash
# This will cause bash to blow its stack and dump core, because the whole trap
# handler is executed in the context where we've been redirected to the bogus
# pipe, generating another SIGPIPE, invoking the handler again, etc.
trap "echo SIGPIPE" PIPE
# This is even sillier. We're defining this trap handler outside of any loop,
# but it only has meaning within a loop. If we're in a loop when the signal
# occurs, we'll break out. If we're not in a loop, we'll get a *syntax error*.
trap "break" INT
while true; do
echo hello
sleep 1
done > /tmp/fubb
echo BYE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment