seanjensengrey / mosh-scheme

Automatically exported from code.google.com/p/mosh-scheme
Other
0 stars 0 forks source link

get-bytevector-all does not work on pipes #229

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
(import (rnrs)
        (mosh process))

(let-values (((in out) (pipe)))
  (let-values (((pid cin cout cerr) (spawn "echo" '("foo") (list #f out #f))))
    (close-port out)
    (write (get-bytevector-all in))
    (newline)
    (close-port in)
    (waitpid pid)))

What is the expected output? What do you see instead?
Expected: #vu8(102 111 111 10)
Got: #<eof-object>

What version of the product are you using? On what operating system?
Git commit 6a638f19c1aff9e3c8c245704042d288a3a301ab
Linux vuurvlieg 3.2.0-1-amd64 #1 SMP Fri Feb 17 05:17:36 UTC 2012 x86_64 
GNU/Linux

Original issue reported on code.google.com by amoe...@gmail.com on 27 Feb 2012 at 7:50

GoogleCodeExporter commented 9 years ago
Please find attached a rough patch for this.
Possible issues with the patch are:
1.  Adds an extra fstat() syscall to every call to get-bytevector-all.
2.  No Windows support, only tested in Linux.
3.  isFIFO() doesn't handle errors, not sure how to go about this?
4.  Adds 2 private methods to FileBinaryInputPort

If you think this approach is OK I can write a test for it in tests/process.scm.

Original comment by amoe...@gmail.com on 27 Feb 2012 at 7:56

Attachments:

GoogleCodeExporter commented 9 years ago
Cc me.

I feel we need additional return value on File::size() at OSCompat.cpp.

ie.) Currently, we have 2 condition for File::size() return value:

-1 = Invalid file descriptor
otherwise = File size

We need additional one;

-2 = Object has indefinite size (eg. pipes)

Original comment by oku...@gmail.com on 29 Feb 2012 at 5:47

GoogleCodeExporter commented 9 years ago
An updated patch is attached implementing this approach plus a test in 
tests/process.scm.

Original comment by amoe...@gmail.com on 5 Mar 2012 at 9:40

Attachments:

GoogleCodeExporter commented 9 years ago
Thank you for your patch.
Will you define or enum the -2 value?

Original comment by hige...@gmail.com on 20 May 2012 at 8:32