Discussion:
[clisp-list] busy waiting detached lisp process
Don Cohen
2017-05-22 14:32:25 UTC
Permalink
I occasionally (not rarely enough) see a clisp process
running at 100% cpu utilization belonging to a user other
than root, with ppid = 1.
I think the process originally had a shell as its parent, which
probably came from an ssh, but at some point the connection was
lost and the clisp process was orphaned.

I don't think the process is doing anything useful or intended,
and would prefer it not use the entire cpu. So I'm wondering
whether anyone has ideas about what causes this or how to fix it,
including
- why the lisp process doesn't die when its parent does
- what the lisp process is actually trying to do (see below),
- whether the lisp code can be improved to avoid this problem
I suspect that one solution is to run lisp inside a call to screen,
but I'm hoping for a solution that doesn't require that.

I tried strace to get some idea what the process is doing and here's
what I see:

mmap(0xcccd81000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xcccd81000
write(1, "\33", 1) = -1 EIO (Input/output error)
write(2, "\n[../src/stream.d:5466] ", 24) = -1 EIO (Input/output error)
setitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={0, 0}}, {it_interval={0, 0}, it_value={0, 0}}) = 0
mmap(0xcccd80000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xcccd80000
write(1, "\33", 1) = -1 EIO (Input/output error)
write(2, "\n[../src/stream.d:5466] ", 24) = -1 EIO (Input/output error)
setitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={0, 0}}, {it_interval={0, 0}, it_value={0, 0}}) = 0
...

Line 5466 of stream.d seems to be the one below calling OS_error.


local maygc const uintB* low_write_array_unbuffered_handle
(object stream, const uintB* byteptr, uintL len, perseverance_t persev) {
var Handle handle = TheHandle(TheStream(stream)->strm_ochannel);
/* On regular file handles, persev_immediate and persev_bonus are effectively
equivalent to persev_partial. Transforming persev_immediate, persev_bonus
here 1) avoids useless system calls for poll(), select() or non-blocking
I/O and 2) improves EOWF detection. */
if ((persev == persev_immediate || persev == persev_bonus)
&& ChannelStream_regular(stream))
persev = persev_partial;
pushSTACK(stream);
var ssize_t result;
GC_SAFE_SYSTEM_CALL(result=, fd_write(handle,byteptr,len,persev));
stream = popSTACK();
if (result<0) { OS_error(); }
/* Safety check whether persev argument was respected or EOWF was reached: */
if ((persev == persev_full && !(result==(sintL)len))
|| (persev == persev_partial && !(result>0)))
error_unwritable(TheSubr(subr_self)->name,stream);
return byteptr+result;
}

Loading...