Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle SIGTERM as SIGINT and ignore SIGHUP #134

Merged
merged 2 commits into from
Jun 6, 2017
Merged

Handle SIGTERM as SIGINT and ignore SIGHUP #134

merged 2 commits into from
Jun 6, 2017

Conversation

DimitriPapadopoulos
Copy link
Collaborator

@DimitriPapadopoulos DimitriPapadopoulos commented May 29, 2017

Not sure about this one:

  • Why do we avoid calling pthread_sigmask() on MacOS X to disable signal handling in future threads?
  • Why are we using C's signal() instead of POSIX sigaction()?

See for example:

Fixes #78.

@Mabin-J
Copy link
Contributor

Mabin-J commented May 30, 2017

In macOS, I got your branch and tested after remove #132 but.. Ctrl + C didn't works...

And...
openfortivpn can be killed with kill pid command but with this PR, it cannot be killed same command.
it was killed with kill -9 pid...

@DimitriPapadopoulos
Copy link
Collaborator Author

DimitriPapadopoulos commented May 30, 2017

@Mabin-J Unfortunately I cannot test on MacOS, however:

  • As far as I know Ctrl + C generates a SIGINT signal on MacOS, same as on Linux.
  • The patch shouldn't change the way SIGINT is handled, it just adds SIGTERM.

So unless I am mistaken this patch shouldn't change Ctrl + C handling at all. Why have you removed #132? Doesn't #132 fix Ctrl + C handling on MacOS?

@DimitriPapadopoulos
Copy link
Collaborator Author

@Mabin-J About kill pid:

What happens with both #134 and #132 applied?

@Mabin-J
Copy link
Contributor

Mabin-J commented May 30, 2017

@DimitriPapadopoulos,
I think that this PR purpose is finishing any situation.
So I tested remove #132.

and... when openfortivpn connect normally, Ctrl + C already worked without this PR...

@DimitriPapadopoulos
Copy link
Collaborator Author

DimitriPapadopoulos commented May 30, 2017

This PR is not about changing handling of Ctrl + C, so I do hope Ctrl + C works the same with or without it.

This PR is for consistent handling of SIGTERM and SIGINT, and for ignoring SIGHUP.

@Mabin-J
Copy link
Contributor

Mabin-J commented May 30, 2017

@DimitriPapadopoulos
Sorry. I understand that this PR's purpose after read your comment and test more situation.

Before this PR, openfortivpn connected normally and run kill pid, It can be finish but without destroy process.
But after thisPR, kill pid can be finish with destroy process.
Right?

It works correctly in macOS. :)

@DimitriPapadopoulos
Copy link
Collaborator Author

@Mabin-J Thanks for testing this PR on MacOS.

I'm still not sure why we avoid calling pthread_sigmask() on MacOS X to disable signal handling in future threads, but that's probably best dealt with in a different issue.

On MacOS X we have not been disabling SIGINT for future spawned threads.
This commit does not disable SIGTERM either. Is that the right thing to do?
What was the matter in the first place with blocking SIGINT for future threads
with pthread_sigmask()?
@DimitriPapadopoulos
Copy link
Collaborator Author

DimitriPapadopoulos commented May 30, 2017

@Mabin-J Indeed this PR should allow for consistent and proper clean-up afterkill pid (SIGTERM) just like after Ctrl + C (SIGINT).

Proper clean-up depends on the signal handler and the related logic of the application. We might need to review and change the current code in openfortivpn, especially for MacOS, but that's a different issue and at least kill pid (SIGTERM) and Ctrl + C (SIGINT) are handled consistently.

@Mabin-J
Copy link
Contributor

Mabin-J commented May 30, 2017

@DimitriPapadopoulos, I understood.

@mrbaseman
Copy link
Collaborator

Sorry if I repeat things that have already been said...

@DimitriPapadopoulos to your question "Why do we avoid calling pthread_sigmask() on MacOS X to disable signal handling in future threads?" I just can say that this was part of the initial MacOS X port fretn@382fefd to which @fretn had added the documentation and which I rebased and squashed end of last year.

If this part of the MacOS X code can be improved, please go ahead. Maybe the #ifndef __APPLE__ (io.c#L577) and #endif (io.c#L584) can just be dropped now?

We have seen yesterday in #132, that openfortivpn works on MacOS X with this part of the signal handling, but it could not be canceled with Ctrl + C anymore in normal operation (actually, that's what the comment on io.c#L578 gives as an explanation. @Mabin-J could you repeat this test with the patches of #134 applied? If it works fine, we can drop these two preprocessor lines together with the current PR, but if signal handling on MacOS X needs further investigation I would vote for a separate issue to address this.

@Mabin-J
Copy link
Contributor

Mabin-J commented May 31, 2017

@mrbaseman, Sorry. I forgot to test that your request. I'll test it tomorrow.

@Mabin-J
Copy link
Contributor

Mabin-J commented Jun 1, 2017

I tested some case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants