-
Notifications
You must be signed in to change notification settings - Fork 28
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
Make stdin a psuedoterminal when isatty is set #1265
base: master
Are you sure you want to change the base?
Conversation
if (stdin_fd == -1) { | ||
fprintf(stderr, "open: %s: %s\n", argv[1], strerror(errno)); | ||
return 127; | ||
// Because we want to be able to read in both file descirptors and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: descirptors
if (stdin_fd == -1) { | ||
fprintf(stderr, "open: %s: %s\n", argv[1], strerror(errno)); | ||
return 127; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move this if
after the if/else
in case atoi
fails for some reason
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
atoi does not tell you if it fails so we can't catch the error :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just meant something like
if (stdin_file[0] == '#') {
stdin_fd = atoi(stdin_file + 1);
} else {
stdin_fd = open(stdin_file, O_RDONLY);
}
if (stdin_fd == -1) {
fprintf(stderr, "open: %s: %s\n", argv[1], strerror(errno));
return 127;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But that's incorrect for the atoi case. The dup/dup2 below will fail if something is wrong with atoi
....maybe the reality is that we should not being using atoi because its a terrible interface lol.
@@ -829,9 +829,17 @@ static void launch(JobTable *jobtable) { | |||
jobtable->imp->pipes[stdout_stream[0]] = entry; | |||
jobtable->imp->pipes[stderr_stream[0]] = entry; | |||
clock_gettime(CLOCK_REALTIME, &entry->job->start); | |||
std::string stdin_file_str = "/dev/null"; | |||
int stdin_stream[2]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not going to block, but I really think this should be explicit via a tuple data in wakelang.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean exactly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mentioned in chat but something like
data StdInOption =
DevNull
Interactive
File (filename)
def job =
makeExecPlan ......
| setPlanStdinOption DevNull
| runJob
Sometimes programs check isatty(STDIN_FILENO) in addition to stderr and stdout to determine if they're using a terminal or not. We should support that case as well as we can. We'd need to perform some surgery on shim-wake to support the case where stdin is a file input but it ALSO has input. So for now we treat setting stdin to a file to be just that and not a pseudo-terminal.