Menu

#13 Netsys messes pipe management

None
wont-fix
nobody
None
5
2014-09-06
2012-08-29
No

Suppose you have an ocaml script file "foobar.ml" containing :

%< %< %< %< %< %< %< %< %< %< %< %< %< %<

#!/usr/bin/ocaml

#use "topfind";;
#require "netsys";;

while true do Printf.printf "toto\n%!"; done

%< %< %< %< %< %< %< %< %< %< %< %< %< %<

The command "ocaml foobar.ml | more" followed by a "q" key press ends up with :

Exception: Sys_error "Broken pipe".
Fatal error: exception Sys_error("Broken pipe")

When not requiring netsys, everything runs smoothly. Seems that the netsys module is messing sigpipe management without noticing.

Discussion

  • Gerd Stolpmann

    Gerd Stolpmann - 2014-09-06

    This is intentional. Without that "messing", the program simply gets a sigpipe and dies (maybe it dies smoothly, I don't know). This way we get at least an exception. You can disable this behaviour with:

    Sys.set_signal Sys.sigpipe Sys.Signal_default;;
    Netsys_signal.keep_away_from Sys.sigpipe;;
    

    I've extended the documentation for Netsys_signal.

     
  • Gerd Stolpmann

    Gerd Stolpmann - 2014-09-06
    • status: open --> wont-fix
    • Group: -->
     

Log in to post a comment.

MongoDB Logo MongoDB