Showcase on capturing and making use of SIG_PIPE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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