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

RecordControl: Exit when input stream closes #17

Merged
merged 1 commit into from
Jun 6, 2016

Conversation

shlevy
Copy link
Contributor

@shlevy shlevy commented May 25, 2016

No description provided.

@jonnew
Copy link
Owner

jonnew commented May 25, 2016

Thanks, Shea. I'm not able to reproduce the fix, though. My test case was

oat record -p pos --interactive &
oat posigen rand2D pos

I then interrupt the position generator and expect oat-record to exit, but it doesn't until I manually provide an endline through stdin.

@shlevy
Copy link
Contributor Author

shlevy commented May 25, 2016

That's just the way job control works in the shell, it won't report that backgrounded processes exit until you next leave and enter the prompt (e.g. try:

$ sleep 10 &
$ cat
<interrupt>
$ <wait ten seconds> <enter>

If you type control-D, it will close stdin for the active process. So just run oat record --interactive, enter as many commands as you want, then hit control-D.

@jonnew
Copy link
Owner

jonnew commented May 25, 2016

Well, I lied a bit. I actually did run the two processes in separate shells. I just wrote that out of expediency. I'm probably still just missing something.

@jonnew jonnew closed this May 25, 2016
@jonnew jonnew reopened this May 25, 2016
@jonnew
Copy link
Owner

jonnew commented May 25, 2016

The 'comment' and 'close' buttons are awfully close together in PR interface...

@shlevy
Copy link
Contributor Author

shlevy commented May 25, 2016

Hmm, this was blind-coded after fixing something on Hector's machine, I'll test when I get back in to the office on Tuesday and report back.

@shlevy
Copy link
Contributor Author

shlevy commented May 25, 2016

Oh, this is just the command input that oat is listening on in interactive mode, nothing to do with the position inputs.

@jonnew
Copy link
Owner

jonnew commented May 25, 2016

Yeah, the position input is just to provide a dummy source to the recorder. I think I see where I was confused:

The default behavior in oat components is to close when the upstream data source exits. When oat-record is in interactive mode, it does not do this because std::getline blocks. It requires the user to put some input into the terminal so std::getline() unblocks, which is what I thought you were getting at.

I think actually you were addressing something else, which I now understand. When the stream is explicitly ended by some client, the record controller should exit. Is that right?

@shlevy
Copy link
Contributor Author

shlevy commented May 25, 2016

This was originally inspired by using oat record --interactive in a pipeline. If you run echo -e start \n pause | oat record --interactive, Oat will see the first two commands but then loop forever getting no input when doing getline because standard input is closed. This patch fixes that.

@jonnew
Copy link
Owner

jonnew commented May 26, 2016

Yes, I understand now. Thanks for the clarification. I'm going to open an issue for my other issue. Thanks for the fix!

@jonnew jonnew merged commit 31b0a81 into jonnew:master Jun 6, 2016
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

Successfully merging this pull request may close these issues.

None yet

2 participants