comparison src/sysdep.c @ 225:12579d965149 r20-4b11

Import from CVS: tag r20-4b11
author cvs
date Mon, 13 Aug 2007 10:11:40 +0200
parents 78478c60bfcd
children 557eaa0339bf
comparison
equal deleted inserted replaced
224:4663b37daab6 225:12579d965149
2440 return open (path, oflag, mode); 2440 return open (path, oflag, mode);
2441 #endif 2441 #endif
2442 } 2442 }
2443 #endif /* ENCAPSULATE_OPEN */ 2443 #endif /* ENCAPSULATE_OPEN */
2444 2444
2445 /* Like sys_open, only when open() is interrupted by EINTR, check for
2446 QUIT. This allows the callers of this function to be interrupted
2447 with C-g when, say, reading from named pipes. However, this should
2448 be used with caution, as it can GC.
2449
2450 This function will not function as expected on systems where open()
2451 is not interrupted by C-g. However, the worst that can happen is
2452 the fallback to simple open(). */
2453 int
2454 interruptible_open (CONST char *path, int oflag, int mode)
2455 {
2456 /* This function can GC */
2457 size_t len = strlen (path);
2458 char *nonreloc = (char *) alloca (len + 1);
2459
2460 /* Must copy PATH, because it might be the data of a Lisp_String,
2461 which could be relocated by GC when checking for QUIT. */
2462 memcpy (nonreloc, path, len + 1);
2463
2464 /* The same as PATHNAME_CONVERT_OUT in sysdep.c. */
2465 GET_C_CHARPTR_EXT_FILENAME_DATA_ALLOCA (nonreloc, nonreloc);
2466
2467 for (;;)
2468 {
2469 int rtnval = open (nonreloc, oflag, mode);
2470 if (!(rtnval == -1 && errno == EINTR))
2471 return rtnval;
2472 /* open() was interrupted. Was QUIT responsible? */
2473 QUIT;
2474 }
2475 }
2445 2476
2446 #ifdef ENCAPSULATE_CLOSE 2477 #ifdef ENCAPSULATE_CLOSE
2447 int 2478 int
2448 sys_close (int fd) 2479 sys_close (int fd)
2449 { 2480 {