Skip to content

Do not block launched process when redirecting output #58

@demarey

Description

@demarey

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions