File: cl-shim.c

package info (click to toggle)
cl-launch 4.1.4-1.1
  • links: PTS
  • area: main
  • in suites: bullseye, sid
  • size: 296 kB
  • sloc: sh: 2,607; lisp: 222; makefile: 127; ansic: 29
file content (35 lines) | stat: -rw-r--r-- 647 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>

#ifndef CL_LAUNCH_SCRIPT
#define CL_LAUNCH_SCRIPT "/usr/bin/cl-launch"
#endif

char me[] = "cl-shim";
char var[] = "CL_ARGV0";
char shell[] = "/bin/sh";

int main (int argc, char**argv) {
  int res;
  size_t l;
  char**args;

  res = setenv(var, argv[0], 1);
  if (res == -1) { perror(me); exit(42); }

  l = (1+argc)*sizeof(char**);
  args = malloc(l);
  if (!args) { exit(42); }

  args[0] = argv[0];
  args[1] = CL_LAUNCH_SCRIPT;
  for(;argc>0;argc--) {
    args[argc+1] = argv[argc];
  }
  res = execv(shell, args);
  perror(me);
  exit(42);
}