Skip to content

Commit

Permalink
Improving process shutdown (better debug reports).
Browse files Browse the repository at this point in the history
  • Loading branch information
lukacu committed May 10, 2017
1 parent fd7c4ff commit 96e055e
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions support/client/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,18 +369,27 @@ class TrackerProcess::State : public Synchronized {
if (process) {
int exit_status;

print_debug("Stopping.");
print_debug("Trying to stop process nicely.");

process->stop(false);
flush_streams();

process->is_alive(&exit_status);
sleepf(0.01);

flush_streams();
process->stop(true, true);
if (process->is_alive(&exit_status)) {
print_debug("Process termination.");
process->stop(true, true);
process->is_alive(&exit_status);
sleepf(0.01);
}

print_debug("Process should be terminated.");

delete process;
process = NULL;

print_debug("Stopping logger.");

reset_logger();

if (exit_status == 0) {
Expand Down Expand Up @@ -432,14 +441,16 @@ class TrackerProcess::State : public Synchronized {

char buffer[LOGGER_BUFFER_SIZE];

while (true) {
for (int i = 0; i < 10; i++) {

int read = read_stream(process->get_error(), buffer, LOGGER_BUFFER_SIZE);

if (read <= 0) break;

client_logger(buffer, read, this);

sleepf(0.05);

}

flush_condition.wait(1000);
Expand Down

0 comments on commit 96e055e

Please sign in to comment.