47 if (progname[0] ==
'/') {
48 launch = strdup(progname);
50 die(1,
"allocating program name buffer");
52 }
else if (strchr(progname,
'/') != NULL) {
53 cwd = get_current_dir_name();
57 char *path = getenv(
"PATH");
62 die(1,
"could not get PATH environment variable");
66 for (token = strtok_r(path,
":", &saveptr); token != NULL; token = strtok_r(NULL,
":", &saveptr)) {
69 if (access(launch, X_OK) == 0)
79 die(1,
"could not locate program \"%s\" to launch \n", progname);
82 if (launch[0] !=
'/') {
83 char *relative = launch;
85 cwd = get_current_dir_name();