src/os/bsd/vm/perfMemory_bsd.cpp

changeset 8177
9f8038f83a6e
parent 7715
f3ffb37f88a6
child 8210
2d23269a45a0
     1.1 --- a/src/os/bsd/vm/perfMemory_bsd.cpp	Thu Oct 29 14:08:19 2015 +0300
     1.2 +++ b/src/os/bsd/vm/perfMemory_bsd.cpp	Tue Nov 17 09:39:45 2015 -0800
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -375,10 +375,23 @@
    1.11      *saved_cwd_fd = result;
    1.12    }
    1.13  
    1.14 -  // Set the current directory to dirname by using the fd of the directory.
    1.15 +  // Set the current directory to dirname by using the fd of the directory and
    1.16 +  // handle errors, otherwise shared memory files will be created in cwd.
    1.17    result = fchdir(fd);
    1.18 -
    1.19 -  return dirp;
    1.20 +  if (result == OS_ERR) {
    1.21 +    if (PrintMiscellaneous && Verbose) {
    1.22 +      warning("could not change to directory %s", dirname);
    1.23 +    }
    1.24 +    if (*saved_cwd_fd != -1) {
    1.25 +      ::close(*saved_cwd_fd);
    1.26 +      *saved_cwd_fd = -1;
    1.27 +    }
    1.28 +    // Close the directory.
    1.29 +    os::closedir(dirp);
    1.30 +    return NULL;
    1.31 +  } else {
    1.32 +    return dirp;
    1.33 +  }
    1.34  }
    1.35  
    1.36  // Close the directory and restore the current working directory.

mercurial