• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* gspawn.c - Process launching
2  *
3  *  Copyright 2000 Red Hat, Inc.
4  *  g_execvpe implementation based on GNU libc execvp:
5  *   Copyright 1991, 92, 95, 96, 97, 98, 99 Free Software Foundation, Inc.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #include "config.h"
22 
23 #include <errno.h>
24 
25 #include "gspawn.h"
26 
27 static inline gint
_g_spawn_exec_err_to_g_error(gint en)28 _g_spawn_exec_err_to_g_error (gint en)
29 {
30   switch (en)
31     {
32 #ifdef EACCES
33     case EACCES:
34       return G_SPAWN_ERROR_ACCES;
35 #endif
36 
37 #ifdef EPERM
38     case EPERM:
39       return G_SPAWN_ERROR_PERM;
40 #endif
41 
42 #ifdef E2BIG
43     case E2BIG:
44       return G_SPAWN_ERROR_TOO_BIG;
45 #endif
46 
47 #ifdef ENOEXEC
48     case ENOEXEC:
49       return G_SPAWN_ERROR_NOEXEC;
50 #endif
51 
52 #ifdef ENAMETOOLONG
53     case ENAMETOOLONG:
54       return G_SPAWN_ERROR_NAMETOOLONG;
55 #endif
56 
57 #ifdef ENOENT
58     case ENOENT:
59       return G_SPAWN_ERROR_NOENT;
60 #endif
61 
62 #ifdef ENOMEM
63     case ENOMEM:
64       return G_SPAWN_ERROR_NOMEM;
65 #endif
66 
67 #ifdef ENOTDIR
68     case ENOTDIR:
69       return G_SPAWN_ERROR_NOTDIR;
70 #endif
71 
72 #ifdef ELOOP
73     case ELOOP:
74       return G_SPAWN_ERROR_LOOP;
75 #endif
76 
77 #ifdef ETXTBUSY
78     case ETXTBUSY:
79       return G_SPAWN_ERROR_TXTBUSY;
80 #endif
81 
82 #ifdef EIO
83     case EIO:
84       return G_SPAWN_ERROR_IO;
85 #endif
86 
87 #ifdef ENFILE
88     case ENFILE:
89       return G_SPAWN_ERROR_NFILE;
90 #endif
91 
92 #ifdef EMFILE
93     case EMFILE:
94       return G_SPAWN_ERROR_MFILE;
95 #endif
96 
97 #ifdef EINVAL
98     case EINVAL:
99       return G_SPAWN_ERROR_INVAL;
100 #endif
101 
102 #ifdef EISDIR
103     case EISDIR:
104       return G_SPAWN_ERROR_ISDIR;
105 #endif
106 
107 #ifdef ELIBBAD
108     case ELIBBAD:
109       return G_SPAWN_ERROR_LIBBAD;
110 #endif
111 
112     default:
113       return G_SPAWN_ERROR_FAILED;
114     }
115 }
116