Changeset d4a75ad
- Timestamp:
- Jun 8, 2009, 7:36:42 PM (15 years ago)
- Branches:
- clfs-1.2, clfs-2.1, clfs-3.0.0-systemd, clfs-3.0.0-sysvinit, master, systemd, sysvinit
- Children:
- b889fe6
- Parents:
- 878afd8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
BOOK/final-system/multilib/multiarch_wrapper.xml
r878afd8 rd4a75ad 29 29 30 30 <screen os="b"><userinput>cat > multiarch_wrapper.c << "EOF" 31 #define _GNU_SOURCE 32 33 #include <errno.h> 34 #include <stdio.h> 35 #include <stdlib.h> 36 #include <sys/types.h> 37 #include <sys/wait.h> 31 38 #include <unistd.h> 32 #include <stdlib.h>33 #include <errno.h>34 #include <string.h>35 39 36 #ifndef USE_ARCH37 # define USE_ARCH"64"40 #ifndef DEF_SUFFIX 41 # define DEF_SUFFIX "64" 38 42 #endif 39 43 … … 41 45 { 42 46 char *filename; 43 char * use_arch;47 char *suffix; 44 48 45 if(!(use_arch = getenv("USE_ARCH"))) 46 use_arch = USE_ARCH; 49 if(!(suffix = getenv("USE_ARCH"))) 50 if(!(suffix = getenv("BUILDENV"))) 51 suffix = DEF_SUFFIX; 47 52 48 filename = (char *) malloc(strlen(argv[0]) + strlen(use_arch) + 2);49 strcpy(filename,argv[0]);50 strcat(filename, "-");51 strcat(filename, use_arch);53 if (asprintf(&filename, "%s-%s", argv[0], suffix) < 0) { 54 perror(argv[0]); 55 return -1; 56 } 52 57 53 execvp(filename, argv); 58 int status = EXIT_FAILURE; 59 pid_t pid = fork(); 60 61 if (pid == 0) { 62 execvp(filename, argv); 63 perror(filename); 64 goto end; 65 } else if (pid < 0) { 66 goto end_error; 67 } else { 68 if (waitpid(pid, &status, 0) != pid) { 69 status = EXIT_FAILURE; 70 goto end_error; 71 } 72 status = WEXITSTATUS(status); 73 } 74 goto end; 75 76 end_error: 54 77 perror(argv[0]); 78 end: 55 79 free(filename); 80 81 return status; 56 82 } 83 57 84 EOF</userinput></screen> 58 85
Note:
See TracChangeset
for help on using the changeset viewer.