< prev index next >

src/os/aix/vm/os_aix.cpp

Print this page


   1 /*
   2  * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright 2012, 2014 SAP AG. All rights reserved.
   4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5  *
   6  * This code is free software; you can redistribute it and/or modify it
   7  * under the terms of the GNU General Public License version 2 only, as
   8  * published by the Free Software Foundation.
   9  *
  10  * This code is distributed in the hope that it will be useful, but WITHOUT
  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.


5125       status = pthread_mutex_unlock(_mutex);
5126       assert (status == 0, "invariant");
5127     } else {
5128       status = pthread_mutex_unlock(_mutex);
5129       assert (status == 0, "invariant");
5130       status = pthread_cond_signal (_cond);
5131       assert (status == 0, "invariant");
5132     }
5133   } else {
5134     pthread_mutex_unlock(_mutex);
5135     assert (status == 0, "invariant");
5136   }
5137 }
5138 
5139 extern char** environ;
5140 
5141 // Run the specified command in a separate process. Return its exit value,
5142 // or -1 on failure (e.g. can't fork a new process).
5143 // Unlike system(), this function can be called from signal handler. It
5144 // doesn't block SIGINT et al.
5145 int os::fork_and_exec(char* cmd) {
5146   char * argv[4] = {"sh", "-c", cmd, NULL};
5147 
5148   pid_t pid = fork();
5149 
5150   if (pid < 0) {
5151     // fork failed
5152     return -1;
5153 
5154   } else if (pid == 0) {
5155     // child process
5156 
5157     // Try to be consistent with system(), which uses "/usr/bin/sh" on AIX.
5158     execve("/usr/bin/sh", argv, environ);
5159 
5160     // execve failed
5161     _exit(-1);
5162 
5163   } else {
5164     // copied from J2SE ..._waitForProcessExit() in UNIXProcess_md.c; we don't
5165     // care about the actual exit code, for now.


   1 /*
   2  * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright 2012, 2014 SAP AG. All rights reserved.
   4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5  *
   6  * This code is free software; you can redistribute it and/or modify it
   7  * under the terms of the GNU General Public License version 2 only, as
   8  * published by the Free Software Foundation.
   9  *
  10  * This code is distributed in the hope that it will be useful, but WITHOUT
  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.


5125       status = pthread_mutex_unlock(_mutex);
5126       assert (status == 0, "invariant");
5127     } else {
5128       status = pthread_mutex_unlock(_mutex);
5129       assert (status == 0, "invariant");
5130       status = pthread_cond_signal (_cond);
5131       assert (status == 0, "invariant");
5132     }
5133   } else {
5134     pthread_mutex_unlock(_mutex);
5135     assert (status == 0, "invariant");
5136   }
5137 }
5138 
5139 extern char** environ;
5140 
5141 // Run the specified command in a separate process. Return its exit value,
5142 // or -1 on failure (e.g. can't fork a new process).
5143 // Unlike system(), this function can be called from signal handler. It
5144 // doesn't block SIGINT et al.
5145 int os::fork_and_exec(char* cmd, bool use_vfork_if_available) {
5146   char * argv[4] = {"sh", "-c", cmd, NULL};
5147 
5148   pid_t pid = fork();
5149 
5150   if (pid < 0) {
5151     // fork failed
5152     return -1;
5153 
5154   } else if (pid == 0) {
5155     // child process
5156 
5157     // Try to be consistent with system(), which uses "/usr/bin/sh" on AIX.
5158     execve("/usr/bin/sh", argv, environ);
5159 
5160     // execve failed
5161     _exit(-1);
5162 
5163   } else {
5164     // copied from J2SE ..._waitForProcessExit() in UNIXProcess_md.c; we don't
5165     // care about the actual exit code, for now.


< prev index next >