PTT
Submit
Submit
選擇語言
正體中文
简体中文
PTT
LinuxDev
[問題] shell background 差異
作者:
shihyuyao
(shihyuyao)
2015-10-21 20:24:15
https://gist.github.com/anonymous/f44a39855f022c280ecd
使用 sh test1.sh 後
ps aux | grep 'my_fork' // 找不到 my_fork 父跟子行程
但是改成 sh test2.sh &
ps 可以看到my_fork 父子行程
好奇為什麼把 & 寫在 test1.sh 裡面為什麼無法看到父跟子行程?
因為我my_fork 程式裡面有 getchar(); 卡住
謝謝
作者: yvb
2015-10-21 22:42:00
因為 shell script 中的 background commands,其 standard input 會被指向 /dev/null .
作者:
shihyuyao
(shihyuyao)
2015-10-21 23:35:00
standard input 會被指向 /dev/null會影響 my_fork程式fork 行程出來?
作者:
leolarrel
(真.粽子無雙)
2015-10-22 14:30:00
不是,yvb的意思是你的重點在於 getchar(); .....如果你想要讓行程暫停,好讓你可以用ps aux驗證,那你可以用sleep 或做一些無窮回圈的事情
作者: yvb
2015-10-22 19:20:00
意思就是, stdin 被指向 /dev/null 時, getchar() 不會卡住.同樣道理, 試試看 sh test2.sh < /dev/null
繼續閱讀
[問題] PCIe suspend
mcdrumer
[問題] fork 透過pipe 做write/read
yshihyu
[問題] qemu 開多個 terminal
yshihyu
[問題] gdb backtrace
gigigigi
[問題] kernel send signal to user space
yshihyu
[問題] 關於file descriptor的問題?
kyle
[問題] 如何使thread擁有高priority卻不影響wifi
wtchen
[問題] 反組譯後重新組譯
a07051226
[心得] 用Raspberry pi 做四軸飛行器
wtchen
[問題] kgdb p current->comm
gigigigi
Links
booklink
Contact Us: admin [ a t ] ucptt.com