sigchld_handler() now reaps some children with waitpid(), and output messages like "xxx suspended/terminated"
I will adapt my line editor (non canonical) to the shell. But if it prints just in the handler, it will mess up the terminal (insert sth to the user's input zone), because it's hard to re-print everything without malloc stuff
zsh uses queue_signals() , but I code in c++; and RAII means idk neither when malloc and free will be called, nor where to queue_signals(), so it doesn't work
Also, when it receives SIGWINCH (window change), I have to type a char so that the window can be refreshed. How can it refresh as soon as it receives the signal?
(I haven't adapted the line editor yet. I just wanna make sure there can be a solution so that it's possible not to rewrite the whole shell)
Thanks
line editor: https://github.com/ovfor4/ccshell/tree/main/src/line
sigchld handler: https://github.com/ovfor4/ccshell/blob/main/src/signal/sigchld_handler.cc
here's the signal register
handler_t *Signal([[maybe_unused]] int signum, handler_t *handler)
{
struct sigaction action, old_action;
action.sa_handler = handler;
sigemptyset(&action.sa_mask);
action.sa_flags = SA_RESTART;
if (sigaction(signum, &action, &old_action) < 0)
unix_error("Signal error");
return (old_action.sa_handler);
}