5703 struct stat buf;
5704 ::close(fd);
5705 while (::stat(filename, &buf) == 0) {
5706 (void)::poll(NULL, 0, 100);
5707 }
5708 } else {
5709 jio_fprintf(stderr,
5710 "Could not open pause file '%s', continuing immediately.\n", filename);
5711 }
5712 }
5713
5714 extern char** environ;
5715
5716 // Run the specified command in a separate process. Return its exit value,
5717 // or -1 on failure (e.g. can't fork a new process).
5718 // Unlike system(), this function can be called from signal handler. It
5719 // doesn't block SIGINT et al.
5720 int os::fork_and_exec(char* cmd) {
5721 const char * argv[4] = {"sh", "-c", cmd, NULL};
5722
5723 pid_t pid = fork();
5724
5725 if (pid < 0) {
5726 // fork failed
5727 return -1;
5728
5729 } else if (pid == 0) {
5730 // child process
5731
5732 execve("/bin/sh", (char* const*)argv, environ);
5733
5734 // execve failed
5735 _exit(-1);
5736
5737 } else {
5738 // copied from J2SE ..._waitForProcessExit() in UNIXProcess_md.c; we don't
5739 // care about the actual exit code, for now.
5740
5741 int status;
5742
5743 // Wait for the child process to exit. This returns immediately if
|
5703 struct stat buf;
5704 ::close(fd);
5705 while (::stat(filename, &buf) == 0) {
5706 (void)::poll(NULL, 0, 100);
5707 }
5708 } else {
5709 jio_fprintf(stderr,
5710 "Could not open pause file '%s', continuing immediately.\n", filename);
5711 }
5712 }
5713
5714 extern char** environ;
5715
5716 // Run the specified command in a separate process. Return its exit value,
5717 // or -1 on failure (e.g. can't fork a new process).
5718 // Unlike system(), this function can be called from signal handler. It
5719 // doesn't block SIGINT et al.
5720 int os::fork_and_exec(char* cmd) {
5721 const char * argv[4] = {"sh", "-c", cmd, NULL};
5722
5723 pid_t pid ;
5724
5725 if (VMError::is_forkmode_vfork()) {
5726 pid = vfork();
5727 } else {
5728 pid = fork();
5729 }
5730
5731 if (pid < 0) {
5732 // fork failed
5733 return -1;
5734
5735 } else if (pid == 0) {
5736 // child process
5737
5738 execve("/bin/sh", (char* const*)argv, environ);
5739
5740 // execve failed
5741 _exit(-1);
5742
5743 } else {
5744 // copied from J2SE ..._waitForProcessExit() in UNIXProcess_md.c; we don't
5745 // care about the actual exit code, for now.
5746
5747 int status;
5748
5749 // Wait for the child process to exit. This returns immediately if
|