Created
January 20, 2018 21:40
-
-
Save isometry/4a90ae1014736fbb4c86abdb8d2c4796 to your computer and use it in GitHub Desktop.
Fake the process name of an arbitrary command to help distinguish between multiple concurrent instances
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
void usage(char *name); | |
int | |
main(int argc, char *argv[]) | |
{ | |
char *rexec; | |
char *nargv[argc-1]; | |
int i; | |
if (argc < 3) | |
usage(argv[0]); | |
nargv[0] = argv[1]; | |
rexec = argv[2]; | |
for (i = 1; argv[i+2]; ++i) | |
{ | |
nargv[i] = argv[i+2]; | |
} | |
nargv[i] = '\0'; | |
exit(execvp(rexec, nargv)); | |
} | |
void | |
usage(char *name) | |
{ | |
fprintf(stderr,"USAGE: %s mask real [arguments ...]\n", name); | |
exit(1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment