[root@GM]# ./protocol &
[root@GM]# 当前线程栈大小:2097152; 栈最小:16384
Success to establish a socket...
Success to bind the socket...
isatty success!
fd->open=5
Set Port Exactly!
上面可以正常执行,
[root@GM]# cat delfile.sh
./protocol &
执行sh delfile.sh后程序报错
Set Port Exactly!
SetupSerial 1: Bad file descriptor
报错部分代码
struct termios options;
/*tcgetattr(fd,&options)得到与fd指向对象的相关参数,并将它们保存于options,该函数还可以测试配置是否正确,该串口是否可用等。若调用成功,函数返回值为0,若调用失败,函数返回值为1.
*/
if ( tcgetattr( fd,&options) != 0)
{
perror("SetupSerial 1");
return(FALSE);
}
求大牛解答一下,为什么在shell执行就会报错呢,直接输命令就能正常执行!
谢谢!
http://www.cnblogs.com/khler/archive/2011/01/28/1947016.html