Terminate/kill a reference app run by python subprocess/shell through udp socket

• Hardware Platform (Jetson / GPU)
Jetson nano
• DeepStream Version
5.0
• JetPack Version (valid for Jetson only)
Jetpack 4.4
• TensorRT Version
7.1.3-1

**• Question **
I am facing a weird problem while running the deepstream reference app. The idea is to run the deepstream app controlled by other devices (windows pc) where I will be able to stop and start a rtsp feed (from a panasonic IP/network camera) by pressing buttons from the windows app.

The camera is connected through a PoE hub with a jetson nano and a windows pc. As for inference and other accelerated processes, I am not using any in this stage of development. I just want the camera feed for now.

The setup in jetson:
A python script for UDP connection. Upon receiving “start_camera_1” it will start a process through python subprocess. Something like this–>

subprocess.Popen('/home/nvidia/jet4_deepstream/start_camera_1.sh', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)

Within the shell script the command for running the deepstream app is–>

deepstream-app -c /home/nvidia/deepstream_test/start_cam_1.txt

Here the text file is the configuration file. And to terminate the process the shell script for subprocess contains the command below →

`killall -s SIGINT deepstream-app`

This setup works perfectly in the beginning, quickly close the camera feed and start again. But the problem rise when it is running for a long time. Upon receiving the kill request it can not terminate the deepstream app. Debugging it I found this error →

nvdc: open: too many files.

So to kill the process I ran this command from another terminal within the jetson →

killall deepstream-app

This time it was able to kill the process and start live feed again but this method raised another issue. When this kill command is applied the feed stops immediately in the jetson, however the port in the PoE hub (connected to the camera) remains busy as the transferring data LED is still blinking. This also shows within the deepstream-app as it says →

error 503: service unavailable.

This also happens if I use other signal like (SIGUSR,SIGKILL, -9 etc). Only the SIGINT command works perfectly within shorter period of time where the reference app is running for less than 2 hours. (maybe even less).

My requirement is to find out a proper termination method of deepstream reference app. I am so sorry that I could not identify whether this problem is rooted in the reference app or the my way of starting/stopping the app. I am attaching the config file and a ps ax result where the feed is running for more than 3 hours.

[NVIDIA_forum]start_cam_1.txt (3.0 KB)

Can you just use our sample apps and some simple script to reproduce the problem? We need to know how to reproduce this problem in our side.

@Fiona.Chen Thank you for your reply. I will add some additional information for better understanding.

Camera used
Panasonic BB-swxxxA

Used app
deepstream-app (from sample app)
I am using this app without changing anything.

configuration for the app
Provided in my first post.

python script command to run the shell script containing deepstream app command

subprocess.Popen('/home/nvidia/jet4_deepstream/start_camera_1.sh', shell=false, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)

Content of start_camera_1 shell script

deepstream-app -c /home/nvidia/deepstream_test/start_cam_1.txt

Kill command which is also executed through a shell script by python subprocess in a similar manner of starting the camera

killall -s SIGINT deepstream-app

Everything related to deepstream, I am using the sample apps and configuration. I am only changing configuration file nothing in the app itself. On the other hand my python script is a simple client-server one that uses UDP connection. Upon receiving a message it performs subsequent shell script. Very simple logic flow.

Issue arises when deepstream-app is killed and restarted. It shows the error service unavailable and streaming can not be start for around 1~2 minutes. The stream comes back automatically after a certain time period (1~2 minutes) without any further command. I am attaching another screenshot of deepstream-app output.

Please let me know if you need anything else. Thank you.

Edit
I also checked whether the problem is due to python script and it turned out running the sample app also creates this issue.

Sorry to bother but no hint till now… can anyone help me out?