mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-15 13:58:32 +00:00
modified switch.c to not create PID file until all modules are loaded
this help init scripts to check when everything is really loaded. Also return 1 when loading modules fails, do not return 255 which can be confused with a segmentation fault or some other more violent code
This commit is contained in:
1 parent
0bdf79b17c
commit
7db91251c8
1 file changed
+5
-8
+5
-8
@@ -894,6 +894,11 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
switch_dir_make_recursive(SWITCH_GLOBAL_dirs.run_dir, SWITCH_DEFAULT_DIR_PERMS, pool);
|
switch_dir_make_recursive(SWITCH_GLOBAL_dirs.run_dir, SWITCH_DEFAULT_DIR_PERMS, pool);
|
||||||
|
|
||||||
|
if (switch_core_init_and_modload(flags, nc ? SWITCH_FALSE : SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) {
|
||||||
|
fprintf(stderr, "Failed to initialize modules: %s\n", err);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (switch_file_open(&fd, pid_path, SWITCH_FOPEN_READ, SWITCH_FPROT_UREAD | SWITCH_FPROT_UWRITE, pool) == SWITCH_STATUS_SUCCESS) {
|
if (switch_file_open(&fd, pid_path, SWITCH_FOPEN_READ, SWITCH_FPROT_UREAD | SWITCH_FPROT_UWRITE, pool) == SWITCH_STATUS_SUCCESS) {
|
||||||
|
|
||||||
old_pid_len = sizeof(old_pid_buffer);
|
old_pid_len = sizeof(old_pid_buffer);
|
||||||
@@ -920,14 +925,6 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
switch_file_write(fd, pid_buffer, &pid_len);
|
switch_file_write(fd, pid_buffer, &pid_len);
|
||||||
|
|
||||||
if (switch_core_init_and_modload(flags, nc ? SWITCH_FALSE : SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) {
|
|
||||||
fprintf(stderr, "Cannot Initialize [%s], deleting pid file [%s]\n", err, pid_path);
|
|
||||||
if (unlink(pid_path) != 0) {
|
|
||||||
fprintf(stderr, "Failed to delete pid file [%s]\n", pid_path);
|
|
||||||
}
|
|
||||||
return 255;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
if (do_wait) {
|
if (do_wait) {
|
||||||
kill(getppid(), SIGUSR2);
|
kill(getppid(), SIGUSR2);
|
||||||
|
|||||||
Reference in new issue
Block a user