Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Showcase on capturing and making use of SIG_PIPE
import sun.misc.Signal;
import sun.misc.SignalHandler;
/**
* Demo on making use of SIG_PIPE
*
*/
public class RespectSigPipe
{
static boolean isPipeRecieved = false;
public RespectSigPipe() {
Signal.handle(new Signal("PIPE"), new SignalHandler() {
@Override
public void handle(Signal arg0) {
isPipeRecieved = true;
}
});
}
private void printToInfinite()
{
while(!isPipeRecieved)
{
System.out.println( "Hello World!!!");
}
}
public static void main( String[] args )
{
RespectSigPipe demo = new RespectSigPipe();
demo.printToInfinite();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.