Changeset 10965


Ignore:
Timestamp:
Oct 3, 2008, 11:52:15 PM (11 years ago)
Author:
gb
Message:

When loading an image, don't try to print strerror(errno) if errno is
0 (and generally be a little more careful not to clobber errno).

Windows currently doesn't map the image (it should, but that'll create
its own set of file-protection issues), so close the fd even if the
load is successful. (Having the fd open while save_application()
writes to it seems to cause all sorts of problems; I have no idea
how that even works, since AFAIK the file gets deleted before
it's written to, but I must be missing something.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lisp-kernel/pmcl-kernel.c

    r10951 r10965  
    18721872load_image(char *path)
    18731873{
    1874   int fd = open(path, O_RDONLY, 0666);
     1874  int fd = open(path, O_RDONLY, 0666), err;
    18751875  LispObj image_nil = 0;
     1876
     1877  errno = 0;
    18761878  if (fd > 0) {
    18771879    openmcl_image_file_header ih;
     
    18811883       we'll instead keep the original file open.
    18821884    */
     1885    err = errno;
    18831886    if (!image_nil) {
    18841887      close(fd);
    18851888    }
     1889#ifdef WINDOWS
     1890    /* We currently don't actually map the image, and leaving the file
     1891       open seems to make it difficult to write to reliably. */
     1892    if (image_nil) {
     1893      close(fd);
     1894    }
     1895#endif
     1896  } else {
     1897    err = errno;
    18861898  }
    18871899  if (image_nil == 0) {
    1888     fprintf(stderr, "Couldn't load lisp heap image from %s:\n%s\n", path, strerror(errno));
     1900    if (err == 0) {
     1901      fprintf(stderr, "Couldn't load lisp heap image from %s\n", path);
     1902    } else {
     1903      fprintf(stderr, "Couldn't load lisp heap image from %s:\n%s\n", path, strerror(err));
     1904    }
    18891905    exit(-1);
    18901906  }
Note: See TracChangeset for help on using the changeset viewer.