相关讨论
请问各位:
linux 2.6内核 mips架构的 getpid系统调用是怎么实现的.
我怎么没找到代码..
原来2.4都能找到.
by
rw99yy
-
内核源码
-
2011-03-02 10:37:40 阅读(4079) 回复(2)
getpid()的返回值是pid_t类型的,那么prinf("%d",getpid*());为什么可以使用%d对它进行格式化输出?
还有就是系统以_t结尾的原始数据类型,如何和现有的数据类型对应?
by
gridpc
-
程序开发
-
2005-12-15 16:20:20 阅读(1258) 回复(6)
getpid()的返回值是pid_t类型的,那么prinf("%d",getpid*());为什么可以使用%d对它进行格式化输出?
还有就是系统以_t结尾的原始数据类型,如何和现有的数据类型对应?
日志中出现的:
getpid: peer died: Error 0
是啥意思哦,望各位大侠指教?
1 #include
2 #include
3 #include
4
5 int main()
6 {
7 pid_t id;
8 id=fork();
9 if(id == -1)
10 {
11 perror("fujinchengdiaoyongshibai");
12 }
13 if(id == 0)
14 {
15 printf("child process id is %d,the father id is %d \n",getpid(),getppid());
16 }
17
18 if(id > 0)
19 {
20 printf("father p...
我看使用原始套接字的程序中,都有使用
setuid(getpid())这个函数,可是我在看
man setuid时发现,该函数的自变量是
当前进程的有效用户ID(the effective user ID of the current process),
我就不明白了,那它为什么不使用setuid(geteuid())呢?
(我也测试了,发现getpid()与geteuid()是不同的)
1.看一段程序
这个程序调用了一个函数getpid(),用于获取当前进程的ID号。
#includestdio.h>
#includeunistd.h>
int main()
{
int id;
id=getpid();
printf("%d",id);
reurn 0;
}
2. getpid()是什么?在哪里声明?在哪里实现?
(1)getpid()是一个POSIX标准的API,用于用户程序从用户态进入到内核态,在内核态读取当前进程的(tack_struct)的Pid,然后
返回给用户态的程序。
(2)getpid()函数在/usr/...
在线程的执行函数中调用getpid得到的什么值啊?应该不是所在进程的进程号吧,主线程中和create的线程中得到的不一致啊。如:
[code]#include
#include
#include
#include
void * thread(void * a);
int main(int argc,char *argv[])
{
pid_t ident;
ident=getpid();
printf("ident:%d\n",ident);
pthread_t id;
pthread_create(&id,NULL,thread,NULL);
}
void * thread(v...
在线程的执行函数中调用getpid得到的什么值啊?应该不是所在进程的进程号吧,主线程中和create的线程中得到的不一致啊。如:
[code]#include
#include
#include
#include
void * thread(void * a);
int main(int argc,char *argv[])
{
pid_t ident;
ident=getpid();
printf("ident:%d\n",ident);
pthread_t id;
pthread_create(&id,NULL,thread,NULL);
}
void * thread(v...
kill(getpid(),sigtstp)中的sigtstp是什么意思?