2 c++ unix linux macos system-calls
我读到 syscall(39) 返回当前进程 id (pid)
那为什么这 2 个程序输出 2 个不同的数字呢?
int main() {
long r = syscall(39);
printf("returned %ld\n", r);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
和:
int main() {
long r = getpid();
printf("returned %ld\n", r);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我在 clion 中运行我的程序,当我更改第一行时,我得到了不同的结果,这真的很奇怪。
在我得到的答案中运行代码(在 macos 中):
returned getpid()=9390 vs. syscall(39)=8340
Run Code Online (Sandbox Code Playgroud)
这真的很奇怪。
在 ubuntu 中,我得到了相同的 pid,这是为什么?
| 归档时间: |
|
| 查看次数: |
114 次 |
| 最近记录: |