Advertisement
peetaur

manipulate command line

Apr 3rd, 2014
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.88 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<stdlib.h>
  4.  
  5. int main(int argc, char** argv) {
  6.     for(int i=0; i<argc; i++) {
  7.         printf("%s\n", argv[i]);
  8.         for(int c=0; c<strlen(argv[i]); c++){
  9.             argv[i][c]='x';
  10.         }
  11.     }
  12.     system("sleep 60");
  13. }
  14. peter@peter:~/tmp/changecl.c$ gcc -std=c99 changecl.c
  15. peter@peter:~/tmp/changecl.c$ ./a.out --help &
  16.  
  17. peter@peter:~/tmp/changecl.c$ echo $!
  18. 1359
  19.  
  20. peter@peter:~/tmp/changecl.c$ ps -ef | grep 1359
  21. peter     1359 19837  0 13:30 pts/19   00:00:00 xxxxxxx xxxxxx
  22. peter     1360  1359  0 13:30 pts/19   00:00:00 sleep 60
  23. peter     1400  1361  0 13:31 pts/20   00:00:00 grep --color=auto 1359
  24.  
  25. peter@peter:~/tmp/changecl.c$ cat /proc/1359/cmdline
  26. xxxxxxxxxxxxx
  27.  
  28. peter@peter:~/tmp/changecl.c$ hexdump -C /proc/1359/cmdline
  29. 00000000  78 78 78 78 78 78 78 00  78 78 78 78 78 78 00     |xxxxxxx.xxxxxx.|
  30. 0000000f
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement