测试进程test的代码
#include <stdio.h>
int main(){
return 0;
}
编译出测试程序:
gcc test.c -o test
测试脚本
#!/bin/sh
num=0
getProperyResult()
{
./test
num=$(($num+1))
return $?
}
main()
{
while(true)
do
getProperyResult
ret=$?
if [ $ret != 0 ] ;then
echo "getProperyResult ERROR:$ret"
return 100;
fi
echo $num
sleep 2
done
}
main
$ ./my.sh
# ./my.sh
./my.sh
1
2
3
4
5
6
7
8
9
10
11
...