2 * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
3 * Copyright (C) 2004-2007 Kim Woelders
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to
7 * deal in the Software without restriction, including without limitation the
8 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 * sell copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies of the Software, its documentation and marketing & publicity
14 * materials, and acknowledgment shall be given in the documentation, materials
15 * and software packages that this Software was used.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36 dsk = DesksGetCurrent();
37 DeskGetArea(dsk, &ax, &ay);
39 Esnprintf(buf, sizeof(buf), "e16/%d:%d:%d,%d", Mode.apps.startup_id,
41 Esetenv("DESKTOP_STARTUP_ID", buf);
45 ExecSetupEnv(int flags)
51 /* Close all file descriptors except the std 3 */
52 for (fd = 3; fd < 1024; fd++)
55 /* Set up env stuff */
56 if (flags & EXEC_SET_LANG)
58 if (flags & EXEC_SET_STARTUP_ID)
63 Esetenv("LD_PRELOAD", ENLIGHTENMENT_LIB "/libhack.so");
68 execApplication(const char *params, int flags)
70 char exe[FILEPATH_LEN_MAX];
78 sscanf(params, "%4000s", exe);
82 Mode.apps.startup_id++;
88 sh = usershell(getuid());
90 if (path_canexec(exe))
92 real_exec = EMALLOC(char, strlen(params) + 6);
96 sprintf(real_exec, "exec %s", params);
98 execl(sh, sh, "-c", real_exec, NULL);
99 /* We should not get here - invalid shell? */
102 if (!Mode.wm.startup)
104 path = path_test(exe, EFILE_ANY);
109 AlertOK(_("There was an error running the program:\n"
111 "This program could not be executed.\n"
112 "This is because the file does not exist.\n"), exe);
115 AlertOK(_("There was an error running the program:\n"
117 "This program could not be executed.\n"
118 "This is most probably because this "
119 "program is not in the\n"
120 "path for your shell which is %s. "
121 "I suggest you read the manual\n"
122 "page for that shell and read up how to "
123 "change or add to your\n"
124 "execution path.\n"), exe, sh);
127 /* it is a node on the filing sys */
134 AlertOK(_("There was an error running the program:\n"
136 "This program could not be executed.\n"
137 "I am unsure as to why you could not "
138 "do this. The file exists,\n"
139 "is a file, and you are allowed to "
140 "execute it. I suggest you look\n"
141 "into this.\n"), path);
142 /* not executable file */
144 AlertOK(_("There was an error running the program:\n"
146 "This program could not be executed.\n"
147 "This is because the file exists, is a "
148 "file, but you are unable\n"
149 "to execute it because you do not "
150 "have execute " "access to this file.\n"), path);
152 /* it's not a file */
157 AlertOK(_("There was an error running the program:\n"
159 "This program could not be executed.\n"
160 "This is because the file is in fact "
161 "a directory.\n"), path);
162 /* its not a file or a dir */
164 AlertOK(_("There was an error running the program:\n"
166 "This program could not be executed.\n"
167 "This is because the file is not a "
168 "regular file.\n"), path);
177 Espawn(int argc __UNUSED__, char **argv)
179 if (!argv || !argv[0])
185 ExecSetupEnv(EXEC_SET_LANG);
187 execvp(argv[0], argv);
189 AlertOK(_("There was an error running the program:\n%s\n"), argv[0]);
194 EspawnCmd(const char *cmd)
199 argv = StrlistDecodeEscaped(cmd, &argc);
201 StrlistFree(argv, argc);