linux - 如何将负整数传递给 renice?

标签 linux libc

有些 bin 使用 getopt 来解析命令选项,比如 renice。
int getopt(int argc, char * const argv[], const char *optstring);

root@m0032:/ # renice -t normal 10 6428  <br/>
root@m0032:/ # ps -p -P| grep com.spreadwin.popinfosc  <br/>
u0_a49    6428  309   658016 21800 30    10    0     0     bg  SyS_epoll_ b6cbb2e0 S com.spreadwin.popinfosc  <br/>
root@m0032:/ #  <br/>
root@m0032:/ # renice -t normal -10 6428  <br/> 
renice: invalid option -- 1  <br/>
USAGE: renice [[-r] [-t TYPE] priority pids ...] [-g pid]  <br/>
1|root@m0032:/ #   <br/>

最佳答案

getopt :

The special argument ‘--’ forces in all cases the end of option scanning.

据此,renice -t normal -- -10 6428 应该可以工作。

关于linux - 如何将负整数传递给 renice?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50967918/

相关文章:

rust - 为什么 `CMSG_SPACE` 在 Rust 中不是常量函数?

linux - 从函数调用 printf 时出现段错误 - 64 位

c - ptrace mprotect调试麻烦

linux - 在bash中同时读取两个文件

C、将数组写入空白处

linux - 如何从 Bash 脚本列出目标 PID 的曾孙 PID?

c - 如何重新定义#defined 值?

linux - CMake 中的跨平台路径

c - "statically allocated"在 libc 中到底意味着什么?每个库实例一个?每个程序实例一个?

gcc - 使用 libc 库进行编译