Skip to content

Instantly share code, notes, and snippets.

@seveas seveas/cmdline.c

Created Apr 14, 2013
What would you like to do?
#include <stdio.h>
#include <string.h>
#include <unistd.h>
void print_cmdline(void);
int main(int argc, char **argv) {
char *end;
end = argv[argc-1] + strlen(argv[argc-1]);
memset(*argv, 'X', end-*argv);
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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.