Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stall when command is not found #71

Open
sirolf2009 opened this issue Nov 1, 2018 · 0 comments
Open

Stall when command is not found #71

sirolf2009 opened this issue Nov 1, 2018 · 0 comments

Comments

@sirolf2009
Copy link

I copied the example in the README.md and when I would try run it, it would just stall forever on waitFor(). The code is in xtend, which is a java dialect

// The command to run in a PTY...
val cmd = #["/bin/sh", "-l" ]
val env = #{"TERM" -> "xterm"}

val pty = PtyProcess.exec(cmd, env);

val os = pty.getOutputStream()
val is = pty.getInputStream()

new Thread[
	new BufferedReader(new InputStreamReader(is)).lines().forEach[println(it)]
].start()
new Thread[
	new BufferedReader(new InputStreamReader(pty.getErrorStream())).lines().forEach[System.err.println(it)]
].start()

println("Waiting")
// wait until the PTY child process terminates...
val result = pty.waitFor();

// free up resources.
pty.destroy();
println(result)

The logs aren't particularly useful

2018-11-01 10:59:44,262 [DEBUG ] ExtractedNative 93 │ Found /tmp/pty4j-linux-x86_64-8391184450079375244 in 0 ms
2018-11-01 10:59:44,262 [DEBUG ] ExtractedNative 98 │ Listed files in 0 ms
2018-11-01 10:59:44,262 [DEBUG ] ExtractedNative 109 │ Checked upToDate in 0 ms
2018-11-01 10:59:44,262 [DEBUG ] ExtractedNative 116 │ Cleared directory in 1 ms
2018-11-01 10:59:44,263 [DEBUG ] ExtractedNative 122 │ Copied [resources/com/pty4j/native/linux/x86_64/libpty.so] in 1 ms
2018-11-01 10:59:44,263 [INFO  ] ExtractedNative 126 │ Extracted pty4j native in 1 ms
waiting

So I wanted to see what the command actually does

$ /bin/sh -l                                                                                                                                              sirolf2009 <[email protected]> sort timeseries 
/bin/sh: 25: source: not found
$ ^C
$ exit
$

I get a source not found, and then a subshell. Which is probably why I was stalling, the subshell was waiting for input. So shouldn't I have seen /bin/sh: 25: source: not found in my console?

Details:
Pty4j v0.8.5

$ uname -a                                                                                                                              
Linux northpool2 4.9.0-8-amd64 #1 SMP Debian 4.9.110-3+deb9u6 (2018-10-08) x86_64 GNU/Linux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant