src/hotspot/os/linux/os_linux.cpp
changeset 52109 101c2b6eacbe
parent 51996 84743156e780
child 52302 912b79d983d9
equal deleted inserted replaced
52108:9c84227836d4 52109:101c2b6eacbe
  5674 
  5674 
  5675 // Run the specified command in a separate process. Return its exit value,
  5675 // Run the specified command in a separate process. Return its exit value,
  5676 // or -1 on failure (e.g. can't fork a new process).
  5676 // or -1 on failure (e.g. can't fork a new process).
  5677 // Unlike system(), this function can be called from signal handler. It
  5677 // Unlike system(), this function can be called from signal handler. It
  5678 // doesn't block SIGINT et al.
  5678 // doesn't block SIGINT et al.
  5679 int os::fork_and_exec(char* cmd) {
  5679 int os::fork_and_exec(char* cmd, bool use_vfork_if_available) {
  5680   const char * argv[4] = {"sh", "-c", cmd, NULL};
  5680   const char * argv[4] = {"sh", "-c", cmd, NULL};
  5681 
  5681 
  5682   pid_t pid = fork();
  5682   pid_t pid ;
       
  5683 
       
  5684   if (use_vfork_if_available) {
       
  5685     pid = vfork();
       
  5686   } else {
       
  5687     pid = fork();
       
  5688   }
  5683 
  5689 
  5684   if (pid < 0) {
  5690   if (pid < 0) {
  5685     // fork failed
  5691     // fork failed
  5686     return -1;
  5692     return -1;
  5687 
  5693