src/os/aix/vm/perfMemory_aix.cpp

changeset 8177
9f8038f83a6e
parent 7515
b9c06f87e476
child 8210
2d23269a45a0
     1.1 --- a/src/os/aix/vm/perfMemory_aix.cpp	Thu Oct 29 14:08:19 2015 +0300
     1.2 +++ b/src/os/aix/vm/perfMemory_aix.cpp	Tue Nov 17 09:39:45 2015 -0800
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
     1.7   * Copyright 2012, 2013 SAP AG. All rights reserved.
     1.8   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.9   *
    1.10 @@ -454,13 +454,27 @@
    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.
    1.37 +//
    1.38  static void close_directory_secure_cwd(DIR* dirp, int saved_cwd_fd) {
    1.39  
    1.40    int result;

mercurial