I think I found a solution.
126 line @ src/input/mpegts/iptv/iptv_pipe.c - 4.2
if (mclk() < im->mm_iptv_respawn_last + sec2mono(2)) {
tvherror(LS_IPTV, "stdin pipe unexpectedly closed: %s",
r < 0 ? strerror(errno) : "No data");
} else {
As I understand it, 'mclk()' is now, and 'im->mm_iptv_respawn_last' is the last started time of a spawn thread. And it checks whether 2 seconds have passed after the last spawn started. If it takes more than 2 seconds to reach the if statement then a new thread starts, otherwise the while loop is broken.
In my case, the condition of the if statement always returned False. That's why too many spawns are generated until timeout.
I think it's because 'im->mm_iptv_respawn_last' is 'long int', but the others are 'long long int'.
I tried to log them with :
tvherror(LS_IPTV, "## mclk() : %lld", mclk());
tvherror(LS_IPTV, "## im->mm_iptv_respawn_last : %lld", (long long int)im->mm_iptv_respawn_last);
tvherror(LS_IPTV, "## sec2mono(2) : %lld", sec2mono(2));
tvherror(LS_IPTV, "## im->mm_iptv_respawn_last + sec2mono(2): %lld", im->mm_iptv_respawn_last + sec2mono(2));
tvherror(LS_IPTV, "## abs(mclk()), abs(im->mm_iptv_respawn_last), abs(sec2mono(2)) : %d, %d, %d", abs(mclk()), abs(im->mm_iptv_respawn_last), abs(sec2mono(2)));
And these are what I'm got :
2019-04-19 16:15:59.445 iptv: ## mclk() : 179301691855
2019-04-19 16:15:59.445 iptv: ## im->mm_iptv_respawn_last : -1087559463
2019-04-19 16:15:59.445 iptv: ## sec2mono(2) : 2000000
2019-04-19 16:15:59.445 iptv: ## im->mm_iptv_respawn_last + sec2mono(2): -1085559463
2019-04-19 16:15:59.445 iptv: ## abs(mclk()), abs(im->mm_iptv_respawn_last), abs(sec2mono(2)) : 1086934577, 1087559463, 2000000
......
2019-04-19 16:15:59.539 iptv: ## mclk() : 179301791965
2019-04-19 16:15:59.539 iptv: ## im->mm_iptv_respawn_last : -1086934577
2019-04-19 16:15:59.539 iptv: ## sec2mono(2) : 2000000
2019-04-19 16:15:59.539 iptv: ## im->mm_iptv_respawn_last + sec2mono(2): -1084934577
2019-04-19 16:15:59.539 iptv: ## abs(mclk()), abs(im->mm_iptv_respawn_last), abs(sec2mono(2)) : 1086834467, 1086934577, 2000000
......
I don't know what values returned on the other systems, the 'im->mm_iptv_respawn_last' returned a negative time value on my RT-AC68U so far. That made a comparison of 'a positive value < a negative value' in the if statement. Therefore, the condition of the if statement always returns False.
My solution is using absolute values of the times, since they are just needed to check duration of a thread but not correct date and time. I'm totally new in C programming for Linux. So this solution has a chance not to work properly.
--- a/src/input/mpegts/iptv/iptv_pipe.c
+++ b/src/input/mpegts/iptv/iptv_pipe.c
@@ -123,7 +123,7 @@ iptv_pipe_read ( iptv_mux_t *im )
spawn_kill(pid, iptv_pipe_kill_sig(im), im->mm_iptv_kill_timeout);
im->mm_iptv_fd = -1;
im->im_data = NULL;
- if (mclk() < im->mm_iptv_respawn_last + sec2mono(2)) {
+ if (abs(mclk()) < abs(im->mm_iptv_respawn_last + sec2mono(2))) {
tvherror(LS_IPTV, "stdin pipe unexpectedly closed: %s",
r < 0 ? strerror(errno) : "No data");
} else {