打开APP
userphoto
未登录

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

开通VIP
Linux中如何使用echo $?查看检查结果
userphoto

2018.04.21

关注
  1 #include <stdio.h>
  2 #include <unistd.h>
  3 #include <sys/types.h>
  4 #include <sys/wait.h>
  5 int main(void){
  6 //    execl("/bin/ps","ps","-o","pid,ppid,comm",NULL);
  7     execl("/bin/ls","ls","-l",NULL);
  8     return 3;
  9 }

​tarena@ubuntu:~/uc/day08$
a.out
总用量 48
-rwxrwxr-x 1 tarena tarena 8381  4月 21 22:32 a.out
-rw-rw-r-- 1 tarena tarena  684  4月 20 15:14 child.c
-rw-rw-r-- 1 tarena tarena  579  4月 21 16:15 day08.txt
-rw-rw-r-- 1 tarena tarena  208  4月 21 23:08 exec.c
-rw-rw-r-- 1 tarena tarena  412  4月 21 12:42 execle.c
-rw-rw-r-- 1 tarena tarena   13  4月 21 22:27 hello.c
-rw-rw-r-- 1 tarena tarena  247  4月 21 22:32 system2.c
-rw-rw-r-- 1 tarena tarena  262  4月 21 22:29 system.c
-rw-rw-r-- 1 tarena tarena  571  4月 20 13:22 wait.c
-rw-rw-r-- 1 tarena tarena  587  4月 20 14:42 waitpid.c
tarena@ubuntu:~/uc/day08$ echo $?
0

​  1 #include <stdio.h>
  2 #include <unistd.h>
  3 #include <sys/types.h>
  4 #include <sys/wait.h>
  5 int main(void){
  6 //    execl("/bin/ps","ps","-o","pid,ppid,comm",NULL);
  7 //    execl("/bin/ls","ls","-l",NULL);
  8     return 3;
  9 }
tarena@ubuntu:~/uc/day08$ a.out
tarena@ubuntu:~/uc/day08$ echo $?
3

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
如何获取进程的线程id?------说说gettid与pthread_self的区别
Linux下execl函数学习
Linux,shell,重定向,管道符,&符号,逻辑与和或,代码案例
linux system函数使用详解
编译busybox错误汇总
linux应用调试技术之GDB和GDBServer
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服