Compare commits
1 Commits
91fff46499
...
165ed6f176
| Author | SHA1 | Date |
|---|---|---|
|
|
165ed6f176 |
|
|
@ -112,8 +112,7 @@ static int do_stop(const char *pidFilename, const bool bShowError, pid_t *pid)
|
|||
}
|
||||
}
|
||||
|
||||
int process_stop_ex(const char *pidFilename,
|
||||
const bool bShowError, bool *force)
|
||||
int process_stop_ex(const char *pidFilename, const bool bShowError)
|
||||
{
|
||||
#define MAX_WAIT_COUNT 300
|
||||
pid_t pid = 0;
|
||||
|
|
@ -121,7 +120,6 @@ int process_stop_ex(const char *pidFilename,
|
|||
int sig;
|
||||
int i;
|
||||
|
||||
*force = false;
|
||||
if ((result=do_stop(pidFilename, bShowError, &pid)) != 0) {
|
||||
return result;
|
||||
}
|
||||
|
|
@ -133,15 +131,14 @@ int process_stop_ex(const char *pidFilename,
|
|||
break;
|
||||
}
|
||||
|
||||
fc_sleep_ms(100);
|
||||
usleep(100 * 1000);
|
||||
}
|
||||
|
||||
if (i == MAX_WAIT_COUNT) {
|
||||
if (kill(pid, SIGKILL) == 0) {
|
||||
fprintf(stderr, "waiting for pid [%d] exit timeout, "
|
||||
"force kill!\n", (int)pid);
|
||||
*force = true;
|
||||
fc_sleep_ms(100);
|
||||
usleep(100 * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -152,16 +149,12 @@ int process_stop_ex(const char *pidFilename,
|
|||
int process_restart(const char *pidFilename)
|
||||
{
|
||||
const bool bShowError = false;
|
||||
bool force;
|
||||
int result;
|
||||
|
||||
result = process_stop_ex(pidFilename, bShowError, &force);
|
||||
result = process_stop_ex(pidFilename, bShowError);
|
||||
if (result == ENOENT || result == ESRCH) {
|
||||
result = 0;
|
||||
} else if (result == 0) {
|
||||
if (force) {
|
||||
sleep(1);
|
||||
}
|
||||
fprintf(stderr, "starting ...\n");
|
||||
}
|
||||
|
||||
|
|
@ -339,6 +332,7 @@ int get_base_path_from_conf_file_ex(const char *filename, char *base_path,
|
|||
|
||||
int process_action(const char *pidFilename, const char *action, bool *stop)
|
||||
{
|
||||
const bool bShowError = true;
|
||||
int result;
|
||||
pid_t pid;
|
||||
|
||||
|
|
@ -351,7 +345,7 @@ int process_action(const char *pidFilename, const char *action, bool *stop)
|
|||
if (strcmp(action, "stop") == 0)
|
||||
{
|
||||
*stop = true;
|
||||
return process_stop(pidFilename);
|
||||
return process_stop_ex(pidFilename, bShowError);
|
||||
}
|
||||
else if (strcmp(action, "status") == 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -39,15 +39,9 @@ int write_to_pid_file(const char *pidFilename);
|
|||
|
||||
int delete_pid_file(const char *pidFilename);
|
||||
|
||||
int process_stop_ex(const char *pidFilename,
|
||||
const bool bShowError, bool *force);
|
||||
int process_stop_ex(const char *pidFilename, const bool bShowError);
|
||||
|
||||
static inline int process_stop(const char *pidFilename)
|
||||
{
|
||||
const bool bShowError = true;
|
||||
bool force;
|
||||
return process_stop_ex(pidFilename, bShowError, &force);
|
||||
}
|
||||
#define process_stop(pidFilename) process_stop_ex(pidFilename, true)
|
||||
|
||||
int process_restart(const char *pidFilename);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue