Artyom Poptsov <poptsov.art...@gmail.com> writes: > Oh sorry, there was a mistake in my previous mail. 'scm_i_fdes_to_port' > is an internal procedure, but 'scm_fdes_to_port' is defined as Guile API > and should be available to Guile programs. Here's its definition: > > SCM > scm_fdes_to_port (int fdes, char *mode, SCM name) > > And the commentary that I quoted really applies to 'scm_fdes_to_port', > not to 'scm_i_fdes_to_port'. > Also note that if there's no requirement to actually implement this in C, there's `fdes->inport' and `fdes->outport' on the Scheme level, so something like the following would be analogous to the C example code posted:
(import (ice-9 binary-ports)) (define (process-fd fd) (let ((port (fdes->inport fd))) (display "read: ") (display (get-bytevector-n port 100)) (display "\n"))) (process-fd (acquire-valid-fd)) You could now just implement `acquire-valid-fd' in C and expose it to Scheme, if that is even necessary. If you have the FD available via e.g. an environment variable, `acquire-valid-fd' can be implemented in Scheme as well. Regards, Rotty -- Andreas Rottmann -- <http://rotty.xx.vu/>