Skip to content

Commit a40721f

Browse files
committed
syscall_fork.c created online with Bitbucket
1 parent a706dca commit a40721f

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
extern char **environ;
2+
3+
#define __NR_test_syscall1 327
4+
5+
_syscall3(ssize_t,write,int,fd,const void *,buf,size_t,count)
6+
7+
_syscall3(long,open,const char *,filename,int,flags,int,mode)
8+
9+
_syscall0(pid_t,getpid)
10+
_syscall0(pid_t,fork)
11+
12+
_syscall2(long,test_syscall1,unsigned int*,pid,unsigned int *,tgid)
13+
//_syscall1(long,test_syscall2,struct syscall *, syscall2)
14+
int main()
15+
{
16+
17+
18+
int ret,ret1;
19+
unsigned int pid,tgid;
20+
21+
char str[1024];
22+
23+
24+
25+
/* ret = snprintf(str,sizeof(str), "the pid of the process is %d\n", getpid());
26+
27+
ret1 = write(STDOUT_FILENO,str,ret+1);
28+
29+
if(ret1<0){ perror("error in write syscall"); exit(1);}
30+
31+
ret1 = getpid();
32+
33+
34+
if(ret1<0){ perror("error in open syscall"); exit(2);}*/
35+
36+
37+
ret1 = test_syscall1(&pid,&tgid);
38+
if(ret1<0) { perror("error in test_syscall"); exit(1); }
39+
40+
printf("test_syscall returned pid %d and tgid %d\n",pid,tgid);
41+
42+
43+
exit(0);
44+
}
45+
46+
47+

0 commit comments

Comments
 (0)