mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-16 00:41:41 +00:00
wrap fork so we can drop priority in child processes
This commit is contained in:
parent
0995d133a6
commit
52eff9451c
@ -2368,6 +2368,9 @@ SWITCH_DECLARE(void) switch_core_recovery_untrack(switch_core_session_t *session
|
|||||||
SWITCH_DECLARE(void) switch_core_recovery_track(switch_core_session_t *session);
|
SWITCH_DECLARE(void) switch_core_recovery_track(switch_core_session_t *session);
|
||||||
SWITCH_DECLARE(void) switch_core_recovery_flush(const char *technology, const char *profile_name);
|
SWITCH_DECLARE(void) switch_core_recovery_flush(const char *technology, const char *profile_name);
|
||||||
|
|
||||||
|
|
||||||
|
SWITCH_DECLARE(pid_t) switch_fork(void);
|
||||||
|
|
||||||
SWITCH_END_EXTERN_C
|
SWITCH_END_EXTERN_C
|
||||||
#endif
|
#endif
|
||||||
/* For Emacs:
|
/* For Emacs:
|
||||||
|
@ -1185,7 +1185,7 @@ int celliax_serial_getstatus_AT(struct celliax_pvt *p)
|
|||||||
|
|
||||||
NOTICA("incoming SMS message:>>>%s<<<\n", CELLIAX_P_LOG, p->sms_message);
|
NOTICA("incoming SMS message:>>>%s<<<\n", CELLIAX_P_LOG, p->sms_message);
|
||||||
pipe(fd1);
|
pipe(fd1);
|
||||||
pid1 = fork();
|
pid1 = switch_fork();
|
||||||
|
|
||||||
if (pid1 == 0) { //child
|
if (pid1 == 0) { //child
|
||||||
int err;
|
int err;
|
||||||
@ -1735,7 +1735,7 @@ int celliax_serial_read_AT(struct celliax_pvt *p, int look_for_ack, int timeout_
|
|||||||
|
|
||||||
NOTICA("incoming SMS message:>>>%s<<<\n", CELLIAX_P_LOG, p->sms_message);
|
NOTICA("incoming SMS message:>>>%s<<<\n", CELLIAX_P_LOG, p->sms_message);
|
||||||
pipe(fd1);
|
pipe(fd1);
|
||||||
pid1 = fork();
|
pid1 = switch_fork();
|
||||||
|
|
||||||
if (pid1 == 0) { //child
|
if (pid1 == 0) { //child
|
||||||
int err;
|
int err;
|
||||||
|
@ -3101,7 +3101,7 @@ int gsmopen_serial_getstatus_AT(private_t *tech_pvt)
|
|||||||
|
|
||||||
DEBUGA_AT("incoming SMS message:---%s---\n", GSMOPEN_P_LOG, p->sms_message);
|
DEBUGA_AT("incoming SMS message:---%s---\n", GSMOPEN_P_LOG, p->sms_message);
|
||||||
pipe(fd1);
|
pipe(fd1);
|
||||||
pid1 = fork();
|
pid1 = switch_fork();
|
||||||
|
|
||||||
if (pid1 == 0) { //child
|
if (pid1 == 0) { //child
|
||||||
int err;
|
int err;
|
||||||
|
@ -108,7 +108,7 @@ static switch_status_t shell_stream_file_open(switch_file_handle_t *handle, cons
|
|||||||
if (pipe(context->fds)) {
|
if (pipe(context->fds)) {
|
||||||
goto error;
|
goto error;
|
||||||
} else { /* good to go */
|
} else { /* good to go */
|
||||||
context->pid = fork();
|
context->pid = switch_fork();
|
||||||
|
|
||||||
if (context->pid < 0) { /* ok maybe not */
|
if (context->pid < 0) { /* ok maybe not */
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -65,7 +65,7 @@ $SIG{CHLD} = "IGNORE";
|
|||||||
|
|
||||||
while (my $request = $scgi->accept) {
|
while (my $request = $scgi->accept) {
|
||||||
# fork every new req into its own process (optional)
|
# fork every new req into its own process (optional)
|
||||||
my $pid = fork();
|
my $pid = switch_fork();
|
||||||
|
|
||||||
if ($pid) {
|
if ($pid) {
|
||||||
$request->close();
|
$request->close();
|
||||||
|
@ -262,7 +262,7 @@ static void daemonize(int do_wait)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pid = fork();
|
pid = switch_fork();
|
||||||
|
|
||||||
switch (pid) {
|
switch (pid) {
|
||||||
case 0: /* child process */
|
case 0: /* child process */
|
||||||
|
@ -2731,15 +2731,33 @@ SWITCH_DECLARE(void) switch_close_extra_files(int *keep, int keep_ttl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
static int switch_system_fork(const char *cmd, switch_bool_t wait)
|
static int switch_system_fork(const char *cmd, switch_bool_t wait)
|
||||||
{
|
{
|
||||||
return switch_system_thread(cmd, wait);
|
return switch_system_thread(cmd, wait);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SWITCH_DECLARE(pid_t) switch_fork(void)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
SWITCH_DECLARE(pid_t) switch_fork(void)
|
||||||
|
{
|
||||||
|
int i = fork();
|
||||||
|
|
||||||
|
if (!i) {
|
||||||
|
set_low_priority();
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int switch_system_fork(const char *cmd, switch_bool_t wait)
|
static int switch_system_fork(const char *cmd, switch_bool_t wait)
|
||||||
{
|
{
|
||||||
int pid;
|
int pid;
|
||||||
@ -2747,7 +2765,7 @@ static int switch_system_fork(const char *cmd, switch_bool_t wait)
|
|||||||
|
|
||||||
switch_core_set_signal_handlers();
|
switch_core_set_signal_handlers();
|
||||||
|
|
||||||
pid = fork();
|
pid = switch_fork();
|
||||||
|
|
||||||
if (pid) {
|
if (pid) {
|
||||||
if (wait) {
|
if (wait) {
|
||||||
@ -2757,7 +2775,6 @@ static int switch_system_fork(const char *cmd, switch_bool_t wait)
|
|||||||
} else {
|
} else {
|
||||||
switch_close_extra_files(NULL, 0);
|
switch_close_extra_files(NULL, 0);
|
||||||
|
|
||||||
set_low_priority();
|
|
||||||
if (system(dcmd) == -1) {
|
if (system(dcmd) == -1) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to execute because of a command error : %s\n", dcmd);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to execute because of a command error : %s\n", dcmd);
|
||||||
}
|
}
|
||||||
@ -2793,7 +2810,7 @@ SWITCH_DECLARE(int) switch_stream_system_fork(const char *cmd, switch_stream_han
|
|||||||
if (pipe(fds)) {
|
if (pipe(fds)) {
|
||||||
goto end;
|
goto end;
|
||||||
} else { /* good to go */
|
} else { /* good to go */
|
||||||
pid = fork();
|
pid = switch_fork();
|
||||||
|
|
||||||
if (pid < 0) { /* ok maybe not */
|
if (pid < 0) { /* ok maybe not */
|
||||||
close(fds[0]);
|
close(fds[0]);
|
||||||
|
@ -1238,7 +1238,7 @@ static FILE *preprocess_exec(const char *cwd, const char *command, FILE *write_f
|
|||||||
if (pipe(fds)) {
|
if (pipe(fds)) {
|
||||||
goto end;
|
goto end;
|
||||||
} else { /* good to go */
|
} else { /* good to go */
|
||||||
pid = fork();
|
pid = switch_fork();
|
||||||
|
|
||||||
if (pid < 0) { /* ok maybe not */
|
if (pid < 0) { /* ok maybe not */
|
||||||
close(fds[0]);
|
close(fds[0]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user