< prev index next >

src/hotspot/os/aix/os_aix.cpp

Print this page




4242 size_t os::current_stack_size() {
4243   AixMisc::stackbounds_t bounds;
4244   bool rc = AixMisc::query_stack_bounds_for_current_thread(&bounds);
4245   guarantee(rc, "Unable to retrieve stack bounds.");
4246   // Align the returned stack size such that the stack low address
4247   // is aligned to page size (Note: base is usually not and we do not care).
4248   // We need to do this because caller code will assume stack low address is
4249   // page aligned and will place guard pages without checking.
4250   address low = bounds.base - bounds.size;
4251   address low_aligned = (address)align_up(low, os::vm_page_size());
4252   size_t s = bounds.base - low_aligned;
4253   return s;
4254 }
4255 
4256 extern char** environ;
4257 
4258 // Run the specified command in a separate process. Return its exit value,
4259 // or -1 on failure (e.g. can't fork a new process).
4260 // Unlike system(), this function can be called from signal handler. It
4261 // doesn't block SIGINT et al.
4262 int os::fork_and_exec(char* cmd) {
4263   char * argv[4] = {"sh", "-c", cmd, NULL};
4264 
4265   pid_t pid = fork();
4266 
4267   if (pid < 0) {
4268     // fork failed
4269     return -1;
4270 
4271   } else if (pid == 0) {
4272     // child process
4273 
4274     // Try to be consistent with system(), which uses "/usr/bin/sh" on AIX.
4275     execve("/usr/bin/sh", argv, environ);
4276 
4277     // execve failed
4278     _exit(-1);
4279 
4280   } else {
4281     // copied from J2SE ..._waitForProcessExit() in UNIXProcess_md.c; we don't
4282     // care about the actual exit code, for now.




4242 size_t os::current_stack_size() {
4243   AixMisc::stackbounds_t bounds;
4244   bool rc = AixMisc::query_stack_bounds_for_current_thread(&bounds);
4245   guarantee(rc, "Unable to retrieve stack bounds.");
4246   // Align the returned stack size such that the stack low address
4247   // is aligned to page size (Note: base is usually not and we do not care).
4248   // We need to do this because caller code will assume stack low address is
4249   // page aligned and will place guard pages without checking.
4250   address low = bounds.base - bounds.size;
4251   address low_aligned = (address)align_up(low, os::vm_page_size());
4252   size_t s = bounds.base - low_aligned;
4253   return s;
4254 }
4255 
4256 extern char** environ;
4257 
4258 // Run the specified command in a separate process. Return its exit value,
4259 // or -1 on failure (e.g. can't fork a new process).
4260 // Unlike system(), this function can be called from signal handler. It
4261 // doesn't block SIGINT et al.
4262 int os::fork_and_exec(char* cmd, bool use_vfork_if_available) {
4263   char * argv[4] = {"sh", "-c", cmd, NULL};
4264 
4265   pid_t pid = fork();
4266 
4267   if (pid < 0) {
4268     // fork failed
4269     return -1;
4270 
4271   } else if (pid == 0) {
4272     // child process
4273 
4274     // Try to be consistent with system(), which uses "/usr/bin/sh" on AIX.
4275     execve("/usr/bin/sh", argv, environ);
4276 
4277     // execve failed
4278     _exit(-1);
4279 
4280   } else {
4281     // copied from J2SE ..._waitForProcessExit() in UNIXProcess_md.c; we don't
4282     // care about the actual exit code, for now.


< prev index next >