main.c (61b63c556c0877ee6d3832ee641bc427ff4d94d6) main.c (c9a3072d13e4b8a6549ecc1db6390a55c7ee2ddf)
1/*
2 * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 * Licensed under the GPL
4 */
5
6#include <stdio.h>
7#include <stdlib.h>
8#include <unistd.h>

--- 59 unchanged lines hidden (view full) ---

68 * handler is hanging for some reason, the UML will just die
69 * after this signal is sent a second time.
70 */
71 action.sa_flags = SA_RESETHAND | SA_NODEFER;
72 action.sa_restorer = NULL;
73 action.sa_handler = last_ditch_exit;
74 if (sigaction(sig, &action, NULL) < 0) {
75 printf("failed to install handler for signal %d - errno = %d\n",
1/*
2 * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 * Licensed under the GPL
4 */
5
6#include <stdio.h>
7#include <stdlib.h>
8#include <unistd.h>

--- 59 unchanged lines hidden (view full) ---

68 * handler is hanging for some reason, the UML will just die
69 * after this signal is sent a second time.
70 */
71 action.sa_flags = SA_RESETHAND | SA_NODEFER;
72 action.sa_restorer = NULL;
73 action.sa_handler = last_ditch_exit;
74 if (sigaction(sig, &action, NULL) < 0) {
75 printf("failed to install handler for signal %d - errno = %d\n",
76 errno);
76 sig, errno);
77 exit(1);
78 }
79}
80
81#define UML_LIB_PATH ":/usr/lib/uml"
82
83static void setup_env_path(void)
84{
85 char *new_path = NULL;
86 char *old_path = NULL;
87 int path_len = 0;
88
89 old_path = getenv("PATH");
90 /*
91 * if no PATH variable is set or it has an empty value
92 * just use the default + /usr/lib/uml
93 */
94 if (!old_path || (path_len = strlen(old_path)) == 0) {
77 exit(1);
78 }
79}
80
81#define UML_LIB_PATH ":/usr/lib/uml"
82
83static void setup_env_path(void)
84{
85 char *new_path = NULL;
86 char *old_path = NULL;
87 int path_len = 0;
88
89 old_path = getenv("PATH");
90 /*
91 * if no PATH variable is set or it has an empty value
92 * just use the default + /usr/lib/uml
93 */
94 if (!old_path || (path_len = strlen(old_path)) == 0) {
95 putenv("PATH=:/bin:/usr/bin/" UML_LIB_PATH);
95 if (putenv("PATH=:/bin:/usr/bin/" UML_LIB_PATH))
96 perror("couldn't putenv");
96 return;
97 }
98
99 /* append /usr/lib/uml to the existing path */
100 path_len += strlen("PATH=" UML_LIB_PATH) + 1;
101 new_path = malloc(path_len);
102 if (!new_path) {
97 return;
98 }
99
100 /* append /usr/lib/uml to the existing path */
101 path_len += strlen("PATH=" UML_LIB_PATH) + 1;
102 new_path = malloc(path_len);
103 if (!new_path) {
103 perror("coudn't malloc to set a new PATH");
104 perror("couldn't malloc to set a new PATH");
104 return;
105 }
106 snprintf(new_path, path_len, "PATH=%s" UML_LIB_PATH, old_path);
105 return;
106 }
107 snprintf(new_path, path_len, "PATH=%s" UML_LIB_PATH, old_path);
107 putenv(new_path);
108 if (putenv(new_path)) {
109 perror("couldn't putenv to set a new PATH");
110 free(new_path);
111 }
108}
109
110extern int uml_exitcode;
111
112extern void scan_elf_aux( char **envp);
113
114int __init main(int argc, char **argv, char **envp)
115{

--- 144 unchanged lines hidden ---
112}
113
114extern int uml_exitcode;
115
116extern void scan_elf_aux( char **envp);
117
118int __init main(int argc, char **argv, char **envp)
119{

--- 144 unchanged lines hidden ---