开发者

how to set up my background process handler

开发者 https://www.devze.com 2023-04-11 21:52 出处:网络
so I\'m writing a shell that can have both foreground and background process. I have a: signal(SIGCHLD, childHandler);

so I'm writing a shell that can have both foreground and background process. I have a:

signal(SIGCHLD, childHandler);

and thus I have handler:

void childHandler(int signum){
    int status开发者_如何学Go, PID;
    PID = waitpid(-1, &signum,WNOHANG);
}

this handler captures both foreground and background children that change state. My shell seems to work for foreground processes. However, as soon as I call a background process, things don't work properly anymore... and I think it may be due to this handler.

Can anyone see if something's wrong/missing?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号