在Linux中获取当前进程ID的方法有以下几种:
echo $$
#include <stdio.h>
#include <unistd.h>
int main() {
pid_t pid = getpid();
printf("Current process ID: %d\n", pid);
return 0;
}
import os
pid = os.getpid()
print("Current process ID:", pid)
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
相关推荐:linux怎么获取当前进程id