MCPcopy Create free account
hub / github.com/coreutils/coreutils / set_program_path

Function set_program_path

src/stdbuf.c:139–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137 dladdr(), pstat_getpathname(), etc. */
138
139static void
140set_program_path (char const *arg)
141{
142 if (strchr (arg, '/')) /* Use absolute or relative paths directly. */
143 {
144 program_path = dir_name (arg);
145 }
146 else
147 {
148 char *path = xreadlink ("/proc/self/exe");
149 if (path)
150 program_path = dir_name (path);
151 else if ((path = getenv ("PATH")))
152 {
153 path = xstrdup (path);
154 for (char *dir = strtok (path, ":"); dir != NULL;
155 dir = strtok (NULL, ":"))
156 {
157 char *candidate = file_name_concat (dir, arg, NULL);
158 if (access (candidate, X_OK) == 0)
159 {
160 program_path = dir_name (candidate);
161 free (candidate);
162 break;
163 }
164 free (candidate);
165 }
166 }
167 free (path);
168 }
169}
170
171static int
172optc_to_fileno (int c)

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected