[ocaml-ctypes] Converting from int to file_descr

Costel Person costel.person at gmail.com
Thu Jun 5 20:20:37 BST 2014


I am trying to call forkpty
pid_t forkpty(int *amaster, char *name, const struct termios *termp, const
struct winsize *winp);

Only care about file descriptor 'amaster' and result : pid_t

All is good:
  let forkpty = foreign "forkpty" (ptr int @-> ptr void @-> ptr void @->
ptr void @-> returning int)

    let amaster : int ptr = allocate int -1 in
    let pid = forkpty amaster null null null in
    let pipefd = !@ amaster

Do not understand how to convert the int representing file descriptor to
 Unix.file_descr

Or use a view to pass a Unix.file_descr as an int to forkpty ?

Any help appreciated ...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ocaml.org/pipermail/ctypes/attachments/20140605/19e70b0c/attachment.html>


More information about the Ctypes mailing list