History

Make it possible not to redirect stderr

Better solution is needed. If atexit handlers are suppressed then accumulated error messages are never presented to the user, some never leave OCaml turf.

malc committed 6 years ago

Commit dccb2e81 parent 0ab298c4 files · +21 −15Browse files

Unified · Split

4 files
  1. config.ml +1 −0
  2. ffi.ml +1 −1
  3. link.c +15 −13
  4. main.ml +4 −1
config.ml+1−0
@@ -85,6 +85,7 @@ and scrollb = int · 84 unmodified lines
8585 and anchor = pageno * top * dtop
8686 and rect = float * float * float * float * float * float * float * float
8787 and infochange = | Memused | Docinfo | Pdim
88+and dupstderr = bool
8889 ;;
8990
9091 class type uioh =
ffi.ml+1−1
@@ -1,7 +1,7 @@
11 open Config;;
22
33 type initparams = (angle * fitmodel * trimparams * texcount * sliceheight *
4− memsize * colorspace * fontpath);;
4+ memsize * colorspace * fontpath * dupstderr);;
55
66 external init : Unix.file_descr -> initparams -> Unix.file_descr = "ml_init";;
77 external seltext : opaque -> (int * int * int * int) -> unit = "ml_seltext";;
link.c+15−13
@@ -3841,19 +3841,6 @@ ML (init (value csock_v, value params_v)) · 3840 unmodified lines
38413841 int ret, texcount, colorspace, mustoresize;
38423842 const char *fontpath;
38433843
3844− if (pipe (state.pfds)) {
3845− err (1, "pipe");
3846− }
3847− for (int ntries = 0; ntries < 1737; ++ntries) {
3848− if (-1 == dup2 (state.pfds[1], 2)) {
3849− if (EINTR == errno) {
3850− continue;
3851− }
3852− err (1, "dup2");
3853− }
3854− break;
3855− }
3856−
38573844 state.csock = Int_val (csock_v);
38583845 state.rotate = Int_val (Field (params_v, 0));
38593846 state.fitmodel = Int_val (Field (params_v, 1));
@@ -3864,6 +3851,21 @@ ML (init (value csock_v, value params_v)) · 4 unmodified lines
38643851 colorspace = Int_val (Field (params_v, 6));
38653852 fontpath = String_val (Field (params_v, 7));
38663853
3854+ if (Int_val (Field (params_v, 8))) {
3855+ if (pipe (state.pfds)) {
3856+ err (1, "pipe");
3857+ }
3858+ for (int ntries = 0; ntries < 1737; ++ntries) {
3859+ if (-1 == dup2 (state.pfds[1], 2)) {
3860+ if (EINTR == errno) {
3861+ continue;
3862+ }
3863+ err (1, "dup2");
3864+ }
3865+ break;
3866+ }
3867+ }
3868+
38673869 #ifdef CIDER
38683870 state.utf8cs = 1;
38693871 #else
main.ml+4−1
@@ -4869,6 +4869,7 @@ let remoteopen path = · 4868 unmodified lines
48694869 let () =
48704870 vlogf := (fun s -> if conf.verbose then print_endline s else ignore s);
48714871 let gcconfig = ref false in
4872+ let redirstderr = ref true in
48724873 let rcmdpath = ref E.s in
48734874 let dcfpath = ref None in
48744875 let pageno = ref None in
@@ -4926,6 +4927,8 @@ let () = · 51 unmodified lines
49264927
49274928 ("-layout-height", Arg.Set_int layouth,
49284929 "<height> layout height html/epub/etc (-1, 0, N)");
4930+
4931+ ("-no-redir-stderr", Arg.Clear redirstderr, " do not redirect stderr");
49294932 ]
49304933 )
49314934 (fun s -> state.path <- s)
@@ -5099,7 +5102,7 @@ let () = · 167 unmodified lines
50995102 Ffi.init cs (
51005103 conf.angle, conf.fitmodel, (conf.trimmargins, conf.trimfuzz),
51015104 conf.texcount, conf.sliceheight, conf.mustoresize,
5102− conf.colorspace, !Config.fontpath
5105+ conf.colorspace, !Config.fontpath, !redirstderr
51035106 );
51045107 List.iter GlArray.enable [`texture_coord; `vertex];
51055108 GlTex.env (`color conf.texturecolor);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t