Skip to content

Instantly share code, notes, and snippets.

@seveas
Created April 14, 2013 09:48
Show Gist options
  • Save seveas/5382136 to your computer and use it in GitHub Desktop.
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