changed App::guardProcess() to return the number of respawn attempts, capped at INT_MAX

This commit is contained in:
hyung-hwan 2018-09-17 10:11:57 +00:00
parent 016e7da24a
commit 9f07886166

View File

@ -448,6 +448,7 @@ int App::set_signal_subscription_no_mutex (int sig, SignalState reqstate, bool i
int App::guardProcess (const SignalSet& signals, const qse_mchar_t* proc_name) int App::guardProcess (const SignalSet& signals, const qse_mchar_t* proc_name)
{ {
SignalState old_ss[QSE_NSIGS]; SignalState old_ss[QSE_NSIGS];
int seq = 0;
for (int i = 0; i < QSE_NSIGS; i++) for (int i = 0; i < QSE_NSIGS; i++)
{ {
@ -460,6 +461,8 @@ int App::guardProcess (const SignalSet& signals, const qse_mchar_t* proc_name)
while (1) while (1)
{ {
if (seq < QSE_TYPE_MAX(int)) ++seq;
pid_t pid = ::fork(); pid_t pid = ::fork();
if (pid == -1) return -1; if (pid == -1) return -1;
if (pid == 0) if (pid == 0)
@ -516,7 +519,7 @@ int App::guardProcess (const SignalSet& signals, const qse_mchar_t* proc_name)
} }
// TODO: if (proc_name) qse_set_proc_name (proc_name); // TODO: if (proc_name) qse_set_proc_name (proc_name);
return 1; // the caller must execute the actual work. return seq; // the caller must execute the actual work.
} }
///////////////////////////////// /////////////////////////////////