clever-tools icon indicating copy to clipboard operation
clever-tools copied to clipboard

Kill `clever ng join` running sub-process on `clever ng leave`

Open RemiBardon opened this issue 4 years ago • 3 comments

Context

When a user joins a networkgroup (clever ng join) with a first terminal, it hangs and wait for a SIGINT/SIGTERM signal.

Problem

If they don't close this first terminal, and run clever ng leave in a second one, it makes them leave the networkgroup and remove all configuration files.

If they now leave from the first terminal (e.g. Ctrl+C), they will have errors.

Proposed solutions

  1. Elegant but risky: When the user leaves from terminal 2, kill the process running in terminal 1. It might cause problems where a user automated these commands. Also, how to get the PID, and would it be possible to store the clever ng join sub-process PID somewhere (would store another thing on the device 😕)?
  2. Safe but not great: Silently leave if errors occur (files not found).
  3. Balanced solution: Show error messages if errors occur on leave, but add informational message saying it might be normal if user left from another terminal.

RemiBardon avatar Feb 15 '21 09:02 RemiBardon

Yeah, could do it too, now that we have a clever ng leave command 💁🏻‍♂️

@hsablonniere What do you think?

RemiBardon avatar Feb 15 '21 09:02 RemiBardon

So a process would listen to the configuration SSE in the background?

RemiBardon avatar Feb 15 '21 09:02 RemiBardon

Btw, I just realize I should add a security to avoid joining a networkgroup twice 💡

Edit: Reported in issue #459

RemiBardon avatar Feb 15 '21 09:02 RemiBardon