Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # [pjb@despina :0.0 c]$ make arg0
- cc arg0.c -o arg0
- # [pjb@despina :0.0 c]$ ./arg0
- argv[0]=./arg0
- # [pjb@despina :0.0 c]$ ( PATH=$(pwd) ; arg0 )
- argv[0]=arg0
- # [pjb@despina :0.0 c]$ $(pwd)/arg0
- argv[0]=/Users/pjb/src/c/arg0
- # [pjb@despina :0.0 c]$ cat arg0.c
- #include <stdio.h>
- int main(int argc,char* argv[]){
- printf("argv[0]=%s\n",argv[0]);
- return 0;
- }
- # [pjb@despina :0.0 c]$
- # [pjb@despina :0.0 c]$ cat arg0.c
- #include <stdio.h>
- #include <unistd.h>
- int main(int argc,char* argv[]){
- if(argc>1){
- char* pname=argv[0];
- argv[0]="You're fucked";
- execv(pname,argv);
- }
- printf("argv[0]=%s\n",argv[0]);
- return 0;
- }
- # [pjb@despina :0.0 c]$ make arg0
- cc arg0.c -o arg0
- # [pjb@despina :0.0 c]$ ./arg0 foo
- argv[0]=You're fucked
- # [pjb@despina :0.0 c]$
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement