Skip to content

Lua sys.io.process hangs if exitCode called before reading from stdout #11946

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

Closed
0b1kn00b opened this issue Jan 27, 2025 · 3 comments
Closed

Comments

@0b1kn00b
Copy link

0b1kn00b commented Jan 27, 2025

haxe 5.0.0-alpha.1+bdae3e7
lua Lua 5.4.7

import sys.io.Process;

class Main {
	static function main() {
		//read then check exitCode
		final proc = new Process("curl", ["-isS","-X","GET","https://api.github.com/repos/HaxeFoundation/haxe/releases"]);
		trace(proc.stdout.readAll().toString());
		
		final code = proc.exitCode(true);//OK
	

		//check exitCode first
		final proc = new Process("curl", ["-isS","-X","GET","https://api.github.com/repos/HaxeFoundation/haxe/releases"]);
		final code = proc.exitCode(true);//HANGs
	}
}

Lua Process Return.tar.gz

@0b1kn00b
Copy link
Author

There are exceptions, I don't quite understand it:

		final proc = new Process("echo", ["'hello world'"]);
		final code = proc.exitCode(true);//OK

@tobil4sk
Copy link
Member

The most likely reason is that the stdout buffer becomes full, which causes the curl process to hang as it cannot print any more to stdout. You have to read stdout to create space again or pass flags into curl that stop it from writing to stdout. I'd imagine that if you try on another target this would reproduce there too.

@0b1kn00b
Copy link
Author

That tracks. I'll close this.

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

2 participants