LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1127|回复: 2

怎样利用shell检查main的返回值

[复制链接]
发表于 2003-12-11 09:44:10 | 显示全部楼层 |阅读模式
apue上说,可以利用shell检查程序的返回值,但我不知道怎样实现。谁能解释一下,谢谢。
发表于 2003-12-11 11:31:26 | 显示全部楼层
after the process's exiting,
use "echo $?" to print the return value.
发表于 2003-12-11 11:43:00 | 显示全部楼层
fork a child and invoke "system" to excute your program.
in the parent process,invoke "wait" or "waitpid" to get the "status".

/* pid_t wait(int * status) ;  pid_t waitpid(pid_t pid,int * status,int options); */

last,use macro "WIFEXITED(status)" to get the value.

you can find these in APUE.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表