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

"autolab submit" should be able to read from standard input #26

Open
4 tasks
zackw opened this issue Feb 8, 2023 · 1 comment
Open
4 tasks

"autolab submit" should be able to read from standard input #26

zackw opened this issue Feb 8, 2023 · 1 comment

Comments

@zackw
Copy link

zackw commented Feb 8, 2023

Currently autolab submit insists on being given the name of a file that both exists and is a "regular file" (file_exists is true only for files that pass stat(file, &st) == 0 && S_ISREG(st.st_mode)). This means it is impossible to get it to read the submission from standard input, which makes it significantly harder to feed a submission to autolab submit from a C program.

Please make at least one, preferably both, of the following changes:

  1. If the file name given on the command line is a single ASCII minus sign (-), read the submission from standard input. (Skip the "does this file exist" check in [], and then all the way down in RawClient::raw_request, change how you call curl_formadd.)
  2. Allow use of /dev/stdin as the file argument, by changing file_exists so that it considers files that exist but aren't regular files, as long as you can read() from them normally. (Probably the right thing is to blacklist S_ISDIR and S_ISBLK and accept anything else.)

Also, whichever of the two changes you make, you need to test that submitting standard input works correctly when stdin is any of:

  • a file that is open but unlinked (e.g. what you get from tmpfile())
  • a pipe
  • a stream-oriented socket (testing socketpair(AF_LOCAL, SOCK_STREAM, 0) sockets should be good enough)
  • a tty

These are in decreasing order of importance, but ideally all of them would work.

@KesterTan
Copy link

Thanks for this issue submission, we'll look into this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants