190 strcpy(addr.sun_path, path); |
190 strcpy(addr.sun_path, path); |
191 ::unlink(path); |
191 ::unlink(path); |
192 res = ::bind(listener, (struct sockaddr*)&addr, sizeof(addr)); |
192 res = ::bind(listener, (struct sockaddr*)&addr, sizeof(addr)); |
193 } |
193 } |
194 if (res == -1) { |
194 if (res == -1) { |
195 sprintf(path, "%s/.java_pid%d", os::get_temp_directory(), os::current_process_id()); |
195 snprintf(path, PATH_MAX+1, "%s/.java_pid%d", |
|
196 os::get_temp_directory(), os::current_process_id()); |
196 strcpy(addr.sun_path, path); |
197 strcpy(addr.sun_path, path); |
197 ::unlink(path); |
198 ::unlink(path); |
198 res = ::bind(listener, (struct sockaddr*)&addr, sizeof(addr)); |
199 res = ::bind(listener, (struct sockaddr*)&addr, sizeof(addr)); |
199 } |
200 } |
200 if (res == -1) { |
201 if (res == -1) { |
458 // or /tmp then this is the trigger to start the attach mechanism |
459 // or /tmp then this is the trigger to start the attach mechanism |
459 bool AttachListener::is_init_trigger() { |
460 bool AttachListener::is_init_trigger() { |
460 if (init_at_startup() || is_initialized()) { |
461 if (init_at_startup() || is_initialized()) { |
461 return false; // initialized at startup or already initialized |
462 return false; // initialized at startup or already initialized |
462 } |
463 } |
463 char fn[32]; |
464 char fn[128]; |
464 sprintf(fn, ".attach_pid%d", os::current_process_id()); |
465 sprintf(fn, ".attach_pid%d", os::current_process_id()); |
465 int ret; |
466 int ret; |
466 struct stat64 st; |
467 struct stat64 st; |
467 RESTARTABLE(::stat64(fn, &st), ret); |
468 RESTARTABLE(::stat64(fn, &st), ret); |
468 if (ret == -1) { |
469 if (ret == -1) { |
469 sprintf(fn, "/tmp/.attach_pid%d", os::current_process_id()); |
470 snprintf(fn, sizeof(fn), "%s/.attach_pid%d", |
|
471 os::get_temp_directory(), os::current_process_id()); |
470 RESTARTABLE(::stat64(fn, &st), ret); |
472 RESTARTABLE(::stat64(fn, &st), ret); |
471 } |
473 } |
472 if (ret == 0) { |
474 if (ret == 0) { |
473 // simple check to avoid starting the attach mechanism when |
475 // simple check to avoid starting the attach mechanism when |
474 // a bogus user creates the file |
476 // a bogus user creates the file |