- 论坛徽章:
- 0
|
本帖最后由 daodaohu123 于 2013-04-25 16:33 编辑
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <unistd.h>
- #include <sys/types.h>
- #include <errno.h>
- int main(){
- pid_t pid;
- printf("current [pid]%d [ppid]%d [gid]%d [pgid]%d\n", getpid(), getppid(), getgid(), getpgid(getppid()));
- if(pid = fork() > 0){
- printf("parent process is exit\n");
- exit(EXIT_SUCCESS);
- }
- else if(-1 == pid){
- printf("%dL[%d]: %s \n", __LINE__, errno, strerror(errno));
- exit(EXIT_FAILURE);
- }
- if(setsid() < 0){
- printf("%dL[%d]: %s \n", __LINE__, errno, strerror(errno));
- exit(EXIT_FAILURE);
- }
- if(setpgrp() < 0){
- printf("%dL[%d]: %s \n", __LINE__, errno, strerror(errno));
- exit(EXIT_FAILURE);
- }
- printf("alter [pid]%d [ppid]%d [gid]%d [pgid]%d\n", getpid(), getppid(), getgid(), getpgid(getppid()));
- return EXIT_SUCCESS;
- }
复制代码 信息提示:29L[1]: Operation not permitted
我感觉是不是setpgrp()操作权限不够的原因,应该怎么处理 |
|