-
Notifications
You must be signed in to change notification settings - Fork 256
100% CPU usage when sxiv is compiled with AUTORELOAD=nop and run in background in a subshell #297
Comments
Thank you for your report. This bug is probably my fault, sorry for that.
Reproduced the behaviour as described with debian jessie, on master. Indeed, check_timeouts() and arl_handle() will be called repeatedly if sxiv is called non-interactive, i.e. the same will happen for The patch suggested is exactly what is needed. Without, arl->fd is 0, thus resembling stdin. In both suggested non-interactive modes there is data available to be read from stdin and thus FD_ISSET true. Same happens when you start sxiv normally and then press e.g. enter in the terminal window. In the originally reported setting stdin is actually |
Thanks for reporting and fixing this bug. |
Hello Bert,
Bert Münnich writes:
Thanks for reporting and fixing this bug.
Thank you very much for the quick merge and for sxiv!
Thanks again to @sdx23 for helping in the analysis of the problem!
Keep up the good work!
|
Closes: xyb3rt#297 Co-authored-by: Sudo Nice <[email protected]> Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/347 Reviewed-by: NRK <[email protected]> Co-authored-by: zood <[email protected]> Co-committed-by: zood <[email protected]>
Running v24 compiled with
AUTORELOAD=nop
in background in a subshell leadsto 100% CPU usage due a lot of select(2) calls, e.g.:
$ ( sxiv 16x16.png & )
Possible interesting lines from ktruss(1):
$ ktruss -id sh -c '( sxiv 16x16.png & )' [...] 10081 1 sxiv __gettimeofday50(0x7f7fff79fce0, 0) = 0 10081 1 sxiv recvmsg(0x3, 0x7f7fff79fba0, 0) Err#35 EAGAIN 10081 1 sxiv __select50(0x4, 0x7f7fff79fd30, 0, 0, 0x7f7fff79fd20) = 1 10081 1 sxiv __gettimeofday50(0x7f7fff79fce0, 0) = 0 10081 1 sxiv recvmsg(0x3, 0x7f7fff79fba0, 0) Err#35 EAGAIN 10081 1 sxiv __select50(0x4, 0x7f7fff79fd30, 0, 0, 0x7f7fff79fd20) = 1 10081 1 sxiv __gettimeofday50(0x7f7fff79fce0, 0) = 0 10081 1 sxiv recvmsg(0x3, 0x7f7fff79fba0, 0) Err#35 EAGAIN 10081 1 sxiv __select50(0x4, 0x7f7fff79fd30, 0, 0, 0x7f7fff79fd20) = 1 10081 1 sxiv __gettimeofday50(0x7f7fff79fce0, 0) = 0 10081 1 sxiv recvmsg(0x3, 0x7f7fff79fba0, 0) Err#35 EAGAIN 10081 1 sxiv __select50(0x4, 0x7f7fff79fd30, 0, 0, 0x7f7fff79fd20) = 1 10081 1 sxiv __gettimeofday50(0x7f7fff79fce0, 0) = 0 10081 1 sxiv recvmsg(0x3, 0x7f7fff79fba0, 0) Err#35 EAGAIN 10081 1 sxiv __select50(0x4, 0x7f7fff79fd30, 0, 0, 0x7f7fff79fd20) = 1 10081 1 sxiv __gettimeofday50(0x7f7fff79fce0, 0) = 0 [...]
This only happens when sxiv is run in the background and in a subshell, there
aren't any problem running sxiv via:
$ sxiv 16x16.png $ sxiv 16x16.png & $ ( sxiv 16x16.png )
Unfortunately I have not figured out why that happens but the following patch
(tested with
v24
, but should cleanly apply also on themaster
branch, ifnot please let me know and I'll adjust it!):
Please note that I have only noticed that on NetBSD, not sure if also other
platforms are affected.
Do not hesitate to contact me if more information, further debugging, etc. is
needed!
Thanks for the attention!
The text was updated successfully, but these errors were encountered: