< prev index next >

src/hotspot/os/solaris/os_solaris.cpp

Print this page




5235 void Parker::unpark() {
5236   int status = os::Solaris::mutex_lock(_mutex);
5237   assert(status == 0, "invariant");
5238   const int s = _counter;
5239   _counter = 1;
5240   status = os::Solaris::mutex_unlock(_mutex);
5241   assert(status == 0, "invariant");
5242 
5243   if (s < 1) {
5244     status = os::Solaris::cond_signal(_cond);
5245     assert(status == 0, "invariant");
5246   }
5247 }
5248 
5249 extern char** environ;
5250 
5251 // Run the specified command in a separate process. Return its exit value,
5252 // or -1 on failure (e.g. can't fork a new process).
5253 // Unlike system(), this function can be called from signal handler. It
5254 // doesn't block SIGINT et al.
5255 int os::fork_and_exec(char* cmd) {
5256   char * argv[4];
5257   argv[0] = (char *)"sh";
5258   argv[1] = (char *)"-c";
5259   argv[2] = cmd;
5260   argv[3] = NULL;
5261 
5262   // fork is async-safe, fork1 is not so can't use in signal handler
5263   pid_t pid;
5264   Thread* t = Thread::current_or_null_safe();
5265   if (t != NULL && t->is_inside_signal_handler()) {
5266     pid = fork();
5267   } else {
5268     pid = fork1();
5269   }
5270 
5271   if (pid < 0) {
5272     // fork failed
5273     warning("fork failed: %s", os::strerror(errno));
5274     return -1;
5275 




5235 void Parker::unpark() {
5236   int status = os::Solaris::mutex_lock(_mutex);
5237   assert(status == 0, "invariant");
5238   const int s = _counter;
5239   _counter = 1;
5240   status = os::Solaris::mutex_unlock(_mutex);
5241   assert(status == 0, "invariant");
5242 
5243   if (s < 1) {
5244     status = os::Solaris::cond_signal(_cond);
5245     assert(status == 0, "invariant");
5246   }
5247 }
5248 
5249 extern char** environ;
5250 
5251 // Run the specified command in a separate process. Return its exit value,
5252 // or -1 on failure (e.g. can't fork a new process).
5253 // Unlike system(), this function can be called from signal handler. It
5254 // doesn't block SIGINT et al.
5255 int os::fork_and_exec(char* cmd, bool use_vfork_if_available) {
5256   char * argv[4];
5257   argv[0] = (char *)"sh";
5258   argv[1] = (char *)"-c";
5259   argv[2] = cmd;
5260   argv[3] = NULL;
5261 
5262   // fork is async-safe, fork1 is not so can't use in signal handler
5263   pid_t pid;
5264   Thread* t = Thread::current_or_null_safe();
5265   if (t != NULL && t->is_inside_signal_handler()) {
5266     pid = fork();
5267   } else {
5268     pid = fork1();
5269   }
5270 
5271   if (pid < 0) {
5272     // fork failed
5273     warning("fork failed: %s", os::strerror(errno));
5274     return -1;
5275 


< prev index next >