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

Clarify whether spawned processes get the current standard streams in docs #1226

Closed
briandfoy opened this issue Feb 28, 2017 · 4 comments
Closed
Labels
docs Documentation issue (primary issue type) update part of "docs" - indicates this is an update for an existing section; rewrite, clarification, etc.

Comments

@briandfoy
Copy link
Contributor

The docs for Proc shell say

$in, $out and $err are the three standard streams of the to-be-launched program, and default to "-", which means they inherit the stream from the parent process.

But, Brad Gilbert notes in my StackOverflow question that Perl 6 won't pass on changes to $*OUT, etc to child processes. This seems wrong to me, but if that's the way it is, that's the way it is. If this is a design decision (much like the early issues with the Java in the 90s to standardize behavior for dissimilar devices), that should be emphasized as a major language decision.

I don't know what the answer is, but if Perl 6 will never pass on the current values of what it tells the user is standard output and so on, it shouldn't say that spawned processes "inherit the stream from the parent process".

@briandfoy briandfoy added the docs Documentation issue (primary issue type) label Feb 28, 2017
@jnthn
Copy link
Contributor

jnthn commented Mar 1, 2017

The docs are arguably not wrong (though unarguably will lead to the same confusion you have). The STDOUT of the process lives in PROCESS::<$OUT>. Declaring a my $*OUT = ... is therefore not actually changing the STDOUT of the process as a whole (which there is, at present, not a way to do). Since handle inheritance is a process level thing, then that leads to the observed behavior.

Whether this is desirable is an entirely separate question. It's certainly inconsistent with %*ENV and $*CWD, which we do make use of when we spawn a new process. To be clear, the reason we use dynamic variables here is because the (OS-level) chdir and setenv are dangerous in a multi-threaded application; the first we expose as PROCESS::<&chdir> if you should really wish to change the process' working directory, and the latter you'll have to get at with NativeCall. Otherwise, programs never really change the working directory or environment, we just reflect the changes when doing things like opening files and spawning processes.

That we reflect changes to $*CWD and %*ENV when spawning a process suggests to me that we should do the same with $*OUT and $*ERR. We can't do handle inheritance at the file descriptor level in the general case, since $*OUT can be bound to pretty much anything (this is how I/O capturing modules are done). But that's not really an obstacle; we'd just read from the process and write to said handles, if we spot they aren't the same as the process-level ones. If others agree, we can RT this and I can look at implementing it.

@coke
Copy link
Collaborator

coke commented Mar 29, 2017

@briandfoy - can you fix the title? It seems to be missing a word.

@briandfoy briandfoy changed the title Do spawned processes get the current Do spawned processes get the current standard streams Mar 29, 2017
@coke coke added the update part of "docs" - indicates this is an update for an existing section; rewrite, clarification, etc. label Aug 26, 2017
@AlexDaniel
Copy link
Member

AlexDaniel commented Sep 3, 2017

Can somebody turn this into a TODO list? Otherwise this ticket looks scary.

@JJ JJ added the TPF Grant label Mar 29, 2018
@JJ JJ changed the title Do spawned processes get the current standard streams Clarify whether spawned processes get the current standard streams in docs Mar 29, 2018
@JJ JJ removed the JJ TPF Grant label May 14, 2018
@JJ
Copy link
Contributor

JJ commented May 15, 2018

Is this about clarification of who gets the standard streams? If so, it's just changing a sentence. This one:

it shouldn't say that spawned processes "inherit the stream from the parent process".

Tells us what to do, right?

JJ added a commit to JJ/my-raku-examples that referenced this issue Jun 27, 2018
@JJ JJ closed this as completed in 41a6409 Jun 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation issue (primary issue type) update part of "docs" - indicates this is an update for an existing section; rewrite, clarification, etc.
Projects
None yet
Development

No branches or pull requests

5 participants