Skip to content

Instantly share code, notes, and snippets.

@seveas
Created April 14, 2013 09:48
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save seveas/5382136 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string.h>
#include <unistd.h>
void print_cmdline(void);
int main(int argc, char **argv) {
char *end;
print_cmdline();
end = argv[argc-1] + strlen(argv[argc-1]);
memset(*argv, 'X', end-*argv);
print_cmdline();
return 0;
}
void print_cmdline() {
FILE* fd = fopen("/proc/self/cmdline", "r");
char buf[1024];
size_t len = fread(buf, 1, 1023, fd);
buf[len] = '\n';
fwrite(buf, len+1, 1, stdout);
fflush(stdout);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment