突破exit 255限制

zecard_fu 2010-07-02 08:47:23
用WEXITSTATUS(int status)宏取得 system(脚本) 后的值。 但脚本中exit X, 这个X 的值不能超过255, 大侠们,有没有什么办法突破这个限制? 用其它方法也行~ 头痛~~
...全文
244 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
zecard_fu 2010-07-07
  • 打赏
  • 举报
回复
返回的值的瓶颈在WEXISTSTATUS(status); 如果这个能突破, 后面的就好说了! 你说的范围可是-126 ~ 127? 我要返回的数可能远大于256呀~~~
fibbery 2010-07-07
  • 打赏
  • 举报
回复
返回的数有范围吗?如果有范围,可以用0~255映射一下,如果不超过256个的话。否则,就必须得想其他办法。
zecard_fu 2010-07-07
  • 打赏
  • 举报
回复
php->C->脚本 那返回就是 脚本->C->php
fibbery 2010-07-05
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 zecard_fu 的回复:]
感觉 写文件做返回 怪怪的~
[/Quote]

谁来用这个返回值?
zecard_fu 2010-07-02
  • 打赏
  • 举报
回复
实验证明是一个byte
notax 2010-07-02
  • 打赏
  • 举报
回复
没记错的话, unix 上 的 exit status, 用了2 bytes
zecard_fu 2010-07-02
  • 打赏
  • 举报
回复
感觉 写文件做返回 怪怪的~
fibbery 2010-07-02
  • 打赏
  • 举报
回复
系统限制,除非有系统参数,否则在程序的角度上解决不了。如果返回值的可能性已经超过256种,那么你可以考虑使用文件记录返回值的办法,比如,把程序的返回值写到文件中,你想些什么就可以写什么,不受系统的限制。
notax 2010-07-02
  • 打赏
  • 举报
回复
哦,是我记错了,对不起,

http://www.chemie.fu-berlin.de/chemnet/use/info/libc/libc_23.html
http://www.chemie.fu-berlin.de/chemnet/use/info/libc/libc_22.html#SEC399


Exit Status

When a program exits, it can return to the parent process a small amount of information about the cause of termination, using the exit status. This is a value between 0 and 255 that the exiting process passes as an argument to exit.
...

Macro: int WEXITSTATUS (int status)
If WIFEXITED is true of status, this macro returns the low-order 8 bits of the exit status value from the child process. See section Exit Status.

...

37,719

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧