comparison src/callproc.c @ 109358:a9586dc942d5

Merge from mainline.
author Katsumi Yamaoka <katsumi@flagship2>
date Mon, 12 Jul 2010 13:21:11 +0000
parents b7a866c9460c
children 9cfc1b90afea
comparison
equal deleted inserted replaced
109240:6f0915b37828 109358:a9586dc942d5
1286 { 1286 {
1287 if (fd >= minfd) 1287 if (fd >= minfd)
1288 return fd; 1288 return fd;
1289 else 1289 else
1290 { 1290 {
1291 int new = dup (fd); 1291 int new;
1292 #ifdef F_DUPFD
1293 new = fcntl (fd, F_DUPFD, minfd);
1294 #else
1295 new = dup (fd);
1296 if (new != -1)
1297 /* Note that we hold the original FD open while we recurse,
1298 to guarantee we'll get a new FD if we need it. */
1299 new = relocate_fd (new, minfd);
1300 #endif
1292 if (new == -1) 1301 if (new == -1)
1293 { 1302 {
1294 char *message1 = "Error while setting up child: "; 1303 const char *message1 = "Error while setting up child: ";
1295 char *errmessage = strerror (errno); 1304 const char *errmessage = strerror (errno);
1296 char *message2 = "\n"; 1305 const char *message2 = "\n";
1297 emacs_write (2, message1, strlen (message1)); 1306 emacs_write (2, message1, strlen (message1));
1298 emacs_write (2, errmessage, strlen (errmessage)); 1307 emacs_write (2, errmessage, strlen (errmessage));
1299 emacs_write (2, message2, strlen (message2)); 1308 emacs_write (2, message2, strlen (message2));
1300 _exit (1); 1309 _exit (1);
1301 } 1310 }
1302 /* Note that we hold the original FD open while we recurse,
1303 to guarantee we'll get a new FD if we need it. */
1304 new = relocate_fd (new, minfd);
1305 emacs_close (fd); 1311 emacs_close (fd);
1306 return new; 1312 return new;
1307 } 1313 }
1308 } 1314 }
1309 1315
1310 static int 1316 static int
1311 getenv_internal_1 (char *var, int varlen, char **value, int *valuelen, Lisp_Object env) 1317 getenv_internal_1 (const char *var, int varlen, char **value, int *valuelen,
1318 Lisp_Object env)
1312 { 1319 {
1313 for (; CONSP (env); env = XCDR (env)) 1320 for (; CONSP (env); env = XCDR (env))
1314 { 1321 {
1315 Lisp_Object entry = XCAR (env); 1322 Lisp_Object entry = XCAR (env);
1316 if (STRINGP (entry) 1323 if (STRINGP (entry)
1340 } 1347 }
1341 return 0; 1348 return 0;
1342 } 1349 }
1343 1350
1344 static int 1351 static int
1345 getenv_internal (char *var, int varlen, char **value, int *valuelen, Lisp_Object frame) 1352 getenv_internal (const char *var, int varlen, char **value, int *valuelen,
1353 Lisp_Object frame)
1346 { 1354 {
1347 /* Try to find VAR in Vprocess_environment first. */ 1355 /* Try to find VAR in Vprocess_environment first. */
1348 if (getenv_internal_1 (var, varlen, value, valuelen, 1356 if (getenv_internal_1 (var, varlen, value, valuelen,
1349 Vprocess_environment)) 1357 Vprocess_environment))
1350 return *value ? 1 : 0; 1358 return *value ? 1 : 0;
1401 } 1409 }
1402 1410
1403 /* A version of getenv that consults the Lisp environment lists, 1411 /* A version of getenv that consults the Lisp environment lists,
1404 easily callable from C. */ 1412 easily callable from C. */
1405 char * 1413 char *
1406 egetenv (char *var) 1414 egetenv (const char *var)
1407 { 1415 {
1408 char *value; 1416 char *value;
1409 int valuelen; 1417 int valuelen;
1410 1418
1411 if (getenv_internal (var, strlen (var), &value, &valuelen, Qnil)) 1419 if (getenv_internal (var, strlen (var), &value, &valuelen, Qnil))