#include<string.h>
#include<stdio.h>
#include<stdlib.h>
#include<fcntl.h>
#include <unistd.h>
#include<string.h>
int main(int argc, char* argv[])
{
int fd;
int ret = 1;
int len = 0;
char fd_name[255];
char str1[255]= {'\0'};
char cmdline[255]= {'\0'};
sprintf( fd_name,"/proc/%d/cmdline",getpid());
fd = open( fd_name,O_RDONLY);
while(ret)
{
ret = read(fd,str1,sizeof(str1));
if(ret == 0)
{break;}
len += strlen(str1)+1;
lseek(fd,len,SEEK_SET);
strncat(cmdline,str1,strlen(str1));
strcat(cmdline," ");
printf("read %d:%s\n",(int)strlen(cmdline),cmdline);
}
cmdline[strlen(cmdline)-1] = '\0';
printf("read %d:%s\n",(int)strlen(cmdline),cmdline);
return 1;
}
#include<stdio.h>
#include<stdlib.h>
#include<fcntl.h>
#include <unistd.h>
#include<string.h>
int main(int argc, char* argv[])
{
int fd;
int ret = 1;
int len = 0;
char fd_name[255];
char str1[255]= {'\0'};
char cmdline[255]= {'\0'};
sprintf( fd_name,"/proc/%d/cmdline",getpid());
fd = open( fd_name,O_RDONLY);
while(ret)
{
ret = read(fd,str1,sizeof(str1));
if(ret == 0)
{break;}
len += strlen(str1)+1;
lseek(fd,len,SEEK_SET);
strncat(cmdline,str1,strlen(str1));
strcat(cmdline," ");
printf("read %d:%s\n",(int)strlen(cmdline),cmdline);
}
cmdline[strlen(cmdline)-1] = '\0';
printf("read %d:%s\n",(int)strlen(cmdline),cmdline);
return 1;
}