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

Do not block launched process when redirecting output #58

Open
demarey opened this issue Jun 16, 2020 · 1 comment
Open

Do not block launched process when redirecting output #58

demarey opened this issue Jun 16, 2020 · 1 comment

Comments

@demarey
Copy link
Contributor

demarey commented Jun 16, 2020

When you run a process, it can write some data to the standard output (or error).
Example:

p := OSSUnixSubprocess new
	command: '/bin/bash';
	arguments: #('-c' '/tmp/pharo-vm/Pharo.app/Contents/MacOS/Pharo /tmp/Pharo.image eval "[ 70 timesRepeat: [ Stdio stderr nextPutAll: (String loremIpsum: 1024). 0.01 second wait. ] ] fork"');
	run.

If you run the process without trying to read the standard error, everything is fine.
Then, if you run the same process, listening to the standard error, the launched process will freeze.

p := OSSUnixSubprocess new
	command: '/bin/bash';
	arguments: #('-c' '/tmp/pharo-vm/Pharo.app/Contents/MacOS/Pharo /tmp/Pharo.image eval "[ 70 timesRepeat: [ Stdio stderr nextPutAll: (String loremIpsum: 1024). 0.01 second wait. ] ] fork"');
	redirectStderr;
	run.

The standard streams have a maximum buffer. When this buffer is full, then the process is paused until someone reads in the buffer and empty it.
OSSubprocess should handle this case by providing a way to signal that data is available. It could be done by using non-blocking ffi calls to read the buffer.

@demarey
Copy link
Contributor Author

demarey commented Jun 16, 2020

Here is a test to reproduce:
OSSubTest.st.txt

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