Created
June 14, 2017 20:24
-
-
Save bertmaher/b3a54a6c4ed0eb5c52da91065af9d029 to your computer and use it in GitHub Desktop.
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 com.zaxxer.nuprocess.*; | |
import java.util.concurrent.*; | |
import java.util.*; | |
class PipeLeakRepro { | |
static class ProcessHandler extends NuAbstractProcessHandler { | |
private NuProcess nuProcess; | |
@Override | |
public void onStart(NuProcess nuProcess) { | |
this.nuProcess = nuProcess; | |
nuProcess.closeStdin(true); | |
} | |
} | |
private static void doNuProcess() throws Exception { | |
NuProcessBuilder pb = new NuProcessBuilder(Arrays.asList("/bin/echo", "test")); | |
ProcessHandler handler = new ProcessHandler(); | |
pb.setProcessListener(handler); | |
NuProcess process = pb.start(); | |
process.waitFor(0, TimeUnit.SECONDS); // when 0 is used for waitFor() the wait is infinite | |
} | |
public static void main(String[] args) throws Exception { | |
int i = 0; | |
while (true) { | |
doNuProcess(); | |
if (i++ == 2048) { | |
System.out.println("pipes start leaking"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment