打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
读指导文档
其他的部分就不用看了。

The tsh Specification

ctrl-c 需要发送到当前前端job,和所有它的后裔。这个是所谓的前台进程组的概念?

The bg <job> command restarts <job> by sending it a SIGCONT signal, and then runs it in
the background. The <job> argument can be either a PID or a JID.
The fg <job> command restarts <job> by sending it a SIGCONT signal, and then runs it in
the foreground. The <job> argument can be either a PID or a JID.

这个是怎么做到的??

tsh should reap all of its zombie children. If any job terminates because it receives a signal that it didn’t catch, then tsh should recognize this event and print a message with the job’s PID and a description of the offending signal.

这个是什么意思?


Hints 
Exceptional Control Flow 不是让你不独异常控制流,兄弟,细心,细心!

The waitpid(), kill(), fork(), execve(), setpgid(), and sigprocmask() functions
will come in very handy. The WUNTRACED and WNOHANG options to waitpid will also be
useful.

kill是用来发送信号的。 setpgid 还没有用 sigprocmask也没有用。 后面两个参数更不知道怎么用哈。

The operating system caps the number of processes any single user can fork. That
said, you will probably want to clean up your environment. The killall and kill commands are
your friends.
kill函数到底是用来干什么的?

When you implement your signal handlers, be sure to send SIGINT and SIGTSTP signals to the en-
tire foreground process group, using “-pid” instead of “pid” in the argument to the kill function.
The sdriver.pl program tests for this error.
为负数就发送到所有的group吗?

One of the tricky parts of the assignment is deciding on the allocation of work between the waitfg
and sigchld handler functions. We recommend the following approach:
– In waitfg, use a busy loop around the sleep function.
– In sigchld handler, use exactly one call to waitpid.

waitfg还不知道在什么使用用。

In eval, the parent must use sigprocmask to block SIGCHLD signals before it forks the child,
and then unblock these signals, again using sigprocmask after it adds the child to the job list by calling addjob. Since children inherit the blocked vectors of their parents, the child must be sure to then unblock SIGCHLD signals before it execs the new program.

竞争条件就是所谓操作通一个list临界区??

The parent needs to block the SIGCHLD signals in this way in order to avoid the race condition where the child is reaped by sigchld handler (and thus removed from the job list) before the parent calls addjob.  在前before?是个什么含义??

When you run your shell from the standard Unix shell, your shell is running in the foreground process group. If your shell then creates a child process, by default that child will also be a member of the foreground process group. Since typing ctrl-c sends a SIGINT to every process in the foreground group, typing ctrl-c will send a SIGINT to your shell, as well as to every process that your shell created, which obviously isn’t correct.
Here is the workaround: After the fork, but before the execve, the child process should call
setpgid(0, 0), which puts the child in a new process group whose group ID is identical to the
child’s PID. This ensures that there will be only one process, your shell, in the foreground process group. When you type ctrl-c, the shell should catch the resulting SIGINT and then forward it to the appropriate foreground job (or more precisely, the process group that contains the foreground job).

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
All about Linux signals | Linux Programming Blog
Learning_the_bash_Shell_Third_Edition 16/n
shell 十三問之第六问:exec 跟 source
python
fork两次如何避免僵尸进程收藏
《UNIX环境高级编程》的笔记——wait&waitpid
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服