Magellan Linux

Contents of /trunk/multiarch-wrapper/multiarch-wrapper.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1150 - (show annotations) (download)
Fri Aug 20 16:59:22 2010 UTC (13 years, 8 months ago) by niro
File MIME type: text/plain
File size: 841 byte(s)
-fixed wrapper to match our buildsystem (multilib.sminc)
1 #define _GNU_SOURCE
2
3 #include <errno.h>
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <sys/types.h>
7 #include <sys/wait.h>
8 #include <unistd.h>
9
10 #ifndef DEF_SUFFIX
11 # define DEF_SUFFIX "m64"
12 #endif
13
14 int main(int argc, char **argv)
15 {
16 char *filename;
17 char *suffix;
18
19 if(!(suffix = getenv("ABI")))
20 suffix = DEF_SUFFIX;
21
22 if (asprintf(&filename, "%s-%s", argv[0], suffix) < 0) {
23 perror(argv[0]);
24 return -1;
25 }
26
27 int status = EXIT_FAILURE;
28 pid_t pid = fork();
29
30 if (pid == 0) {
31 execvp(filename, argv);
32 perror(filename);
33 goto end;
34 } else if (pid < 0) {
35 goto end_error;
36 } else {
37 if (waitpid(pid, &status, 0) != pid) {
38 status = EXIT_FAILURE;
39 goto end_error;
40 }
41 status = WEXITSTATUS(status);
42 }
43 goto end;
44
45 end_error:
46 perror(argv[0]);
47 end:
48 free(filename);
49
50 return status;
51 }
52
53