diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /support/hypertex/tanmoy/X/newpg.c |
Initial commit
Diffstat (limited to 'support/hypertex/tanmoy/X/newpg.c')
-rw-r--r-- | support/hypertex/tanmoy/X/newpg.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/support/hypertex/tanmoy/X/newpg.c b/support/hypertex/tanmoy/X/newpg.c new file mode 100644 index 0000000000..d17832f49e --- /dev/null +++ b/support/hypertex/tanmoy/X/newpg.c @@ -0,0 +1,37 @@ +#include <stdlib.h> +#include <stdio.h> +#include <sys/types.h> + +#ifndef EXIT_FAILURE + #define EXIT_FAILURE 1 +#endif + +#define abrt() return EXIT_FAILURE + +int main(int argc, char *argv[]) +{ + pid_t pgid, pid=0; int arg1; + + if (argc < 3) { + fprintf(stderr,"Usage: %s pgid command args\n",argv[0]); + abrt(); + } + + if(sscanf(argv[1],"%d",&arg1)!=1) { + fprintf(stderr,"Usage: %s pgid command args\n",argv[0]); + abrt(); + } + pgid = arg1; + + if (setpgid(0,pgid)) { + fprintf(stderr,"Error changing pgid\n"); + abrt(); + } + + if(execvp(argv[2],&argv[2])) { + fprintf(stderr,"Error execvping\n"); + abrt(); + } + + return 0; /* Impossible */ +} |