diff options
Diffstat (limited to 'adapter/protocol/man.nim')
-rw-r--r-- | adapter/protocol/man.nim | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/adapter/protocol/man.nim b/adapter/protocol/man.nim index 50521ca1..1b0724ad 100644 --- a/adapter/protocol/man.nim +++ b/adapter/protocol/man.nim @@ -125,10 +125,13 @@ proc processManpage(ofile, efile: File; header, keyword: string) = # message to stdout. But it's much better (faster) than not streaming the # output. if not ofile.readLine(line) or ofile.endOfFile(): - stdout.write("Cha-Control: ConnectionError 4 " & efile.readErrorMsg(line)) - ofile.close() - efile.close() - quit(1) + var wstatus: cint + discard wait(addr wstatus) + if not WIFEXITED(wstatus) or WEXITSTATUS(wstatus) != 0: + stdout.write("Cha-Control: ConnectionError 4 " & efile.readErrorMsg(line)) + ofile.close() + efile.close() + quit(1) # skip formatting of line 0, like w3mman does # this is useful because otherwise the header would get caught in the man # regex, and that makes navigation slightly more annoying @@ -301,10 +304,13 @@ proc doKeyword(man, keyword, section: string) = quit(1) var line: string if not ofile.readLine(line) or ofile.endOfFile(): - stdout.write("Cha-Control: ConnectionError 4 " & efile.readErrorMsg(line)) - ofile.close() - efile.close() - quit(1) + var wstatus: cint + discard wait(addr wstatus) + if not WIFEXITED(wstatus) or WEXITSTATUS(wstatus) != 0: + stdout.write("Cha-Control: ConnectionError 4 " & efile.readErrorMsg(line)) + ofile.close() + efile.close() + quit(1) stdout.write("Content-Type: text/html\n\n") stdout.write("<title>man" & sectionOpt & " -k " & keyword & "</title>\n") stdout.write("<h1>man" & sectionOpt & " -k <b>" & keyword & "</b></h1>\n") |