* fix #9634 debugging a program using execCmdEx now works * only apply EINTR to c_gets for now This reverts commit c0f5305b5a0b46983dfd27e3d77ecbf4f8744dcc.
This commit is contained in:
parent
1f7c907e7d
commit
39ba502f87
1 changed files with 15 additions and 2 deletions
|
|
@ -145,6 +145,7 @@ proc strerror(errnum: cint): cstring {.importc, header: "<string.h>".}
|
||||||
when not defined(NimScript):
|
when not defined(NimScript):
|
||||||
var
|
var
|
||||||
errno {.importc, header: "<errno.h>".}: cint ## error variable
|
errno {.importc, header: "<errno.h>".}: cint ## error variable
|
||||||
|
EINTR {.importc: "EINTR", header: "<errno.h>".}: cint
|
||||||
|
|
||||||
proc checkErr(f: File) =
|
proc checkErr(f: File) =
|
||||||
when not defined(NimScript):
|
when not defined(NimScript):
|
||||||
|
|
@ -319,8 +320,20 @@ proc readLine*(f: File, line: var TaintedString): bool {.tags: [ReadIOEffect],
|
||||||
# fgets doesn't append an \L
|
# fgets doesn't append an \L
|
||||||
for i in 0..<sp: line.string[pos+i] = '\L'
|
for i in 0..<sp: line.string[pos+i] = '\L'
|
||||||
|
|
||||||
var fgetsSuccess = c_fgets(addr line.string[pos], sp.cint, f) != nil
|
var fgetsSuccess: bool
|
||||||
if not fgetsSuccess: checkErr(f)
|
while true:
|
||||||
|
# fixes #9634; this pattern may need to be abstracted as a template if reused;
|
||||||
|
# likely other io procs need this for correctness.
|
||||||
|
fgetsSuccess = c_fgets(addr line.string[pos], sp.cint, f) != nil
|
||||||
|
if fgetsSuccess: break
|
||||||
|
when not defined(NimScript):
|
||||||
|
if errno == EINTR:
|
||||||
|
errno = 0
|
||||||
|
c_clearerr(f)
|
||||||
|
continue
|
||||||
|
checkErr(f)
|
||||||
|
break
|
||||||
|
|
||||||
let m = c_memchr(addr line.string[pos], '\L'.ord, cast[csize_t](sp))
|
let m = c_memchr(addr line.string[pos], '\L'.ord, cast[csize_t](sp))
|
||||||
if m != nil:
|
if m != nil:
|
||||||
# \l found: Could be our own or the one by fgets, in any case, we're done
|
# \l found: Could be our own or the one by fgets, in any case, we're done
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue