Ctrl-C
91–94 of 94 posts
Re: Ctrl-C
#92Re: Ctrl-C
#93Earlier quoted context omitted.
A separate thread with sigwait() may be easier. Though I must admit, I've rarely had to do that manually, as I'm usually using a language or framework that gives an easier way to get notified about signals (e.g. Python KeyboardInterrupt or listeners in Boost ASIO or libuv). Aside from saving some boilerplate, those also emulate equivalent signals in Windows. Threads waiting on event loops is exactly what you want on…
I never use sigwait() or sigsuspend() -- I just have signal handlers that write a byte (e.g., the signal number) into a pipe, and maybe they set a global volatile sig_atomic_t variable. DJB calls this a "self-pipe". A self-pipe turns signals into I/O events that select/poll/epoll/event ports/kqueue/io_ring/whatever can handle like any other events. At exit time I just make sure every thread can get an event. The main…
Re: Ctrl-C
#94Earlier quoted context omitted.
Excellent advice, thanks for sharing. Would in turn recommend using CopyQ to store this tips (and other like it) as a pinned items in folder with explanations for use two years later, that's how I personally stay on top of terminal kung-fu without overloading the consciousness-in-meat* * https://www.mit.edu/people/dpolicar/writing/prose/text/think...
I wouldn't call this excellent advice - kill -9 will rob the process of the opportunity to clean up after itself and leave everything in a good state (e.g. any binary files being manipulated by the application). So I would use this as a last resort - start with Ctrl+C and then "kill INT %1" and then "kill TERM %1" before "kill KILL %1". (For those who don't know "kill KILL" is equivalent to "kill -9". And despite the…
" "kill INT %1" and then "kill TERM %1" before "kill KILL %1". "
is good advice as progressive measures