freeswitch icon indicating copy to clipboard operation
freeswitch copied to clipboard

bg_system leaves zombie processes

Open greenbea opened this issue 3 years ago • 5 comments

Describe the bug Using bg_system by default uses fork() without waitpid, thus creating zombie processes

To Reproduce

fs_cli -x "bg_system echo hello"
ps -aux | grep freeswitch | grep 'Z'

greenbea avatar Sep 08 '22 15:09 greenbea

I can't replicate this, please attach additional details, like OS, and such.

briankwest avatar Nov 16 '22 23:11 briankwest

Debian buster I tested this on multiple machines Screenshot 2022-11-17 011036

greenbea avatar Nov 17 '22 06:11 greenbea

I can confirm this behaviour.

Debian GNU/Linux 11 (bullseye) Version 1.10.9-release+git~20230211T170413Z~e3d966f196~64bit

hheedfeld avatar Feb 17 '23 05:02 hheedfeld

Problem can be solved by adding <param name="threaded-system-exec" value="true"/> to switch.conf.xml

hheedfeld avatar Apr 17 '25 11:04 hheedfeld

CONFIRMED. I have an XML dialplan record that runs "bgsystem" (no underscore) to fork a simple shell script as a test before applying this to a production system that sends an e-mail via bgsystem. Currently it leaves a defunct process for each invocation, but after setting threaded-system-exec=true as indicated above it no longer leaves defunct processes. TNX!

<extension name="nofunct test">
	<condition field="destination_number" expression="^9199$">
		<action application="answer"/>
		<action application="bgsystem" data="/usr/local/freeswitch/scripts/push.sh"/>
		<action application="playback" data="tone_stream://L=3;%(100,100,1004)"/>
		<action application="hangup"/>
	</condition>
</extension>

push.sh
#!/bin/bash
echo "foodoo was here at `date` " >> /usr/local/freeswitch/scripts/outpush.txt

boteman avatar Apr 17 '25 23:04 boteman