Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@alexanderkyte
Copy link
Contributor

@alexanderkyte alexanderkyte commented Apr 13, 2018

Fixes #8236

@alexanderkyte
Copy link
Contributor Author

Fixes #8236

@kumpera
Copy link
Contributor

kumpera commented Apr 13, 2018

What's the impact will that have on regular usage of ctrl+c from CLI usage?

@migueldeicaza
Copy link
Contributor

I dont think we want to do this for SIGTERM, Rodrigo brings up a good case for why not.

@vargaz
Copy link
Contributor

vargaz commented Apr 13, 2018

Yes, users expect ctlr+c to just terminate the app without doing anything else.

@alexanderkyte
Copy link
Contributor Author

Ctrl+c sends a sigint, sigterm is sent by Force Quit and by POSIX kill .

@alexanderkyte
Copy link
Contributor Author

SIGTERM is like SIGKILL, but the dying process is allowed resources to shut down cleanly. This was requested by VS4M for detecting force quit of applications due to hangs.

@alexanderkyte
Copy link
Contributor Author

@monojenkins build pkg

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be documented in man/mono.1.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use g_hasenv

@lewurm
Copy link
Contributor

lewurm commented Apr 13, 2018

How about having another icall to enable this feature (instead of an env var). The MERP stuff is enabled by an icall too, so VSfM won't have to turn knobs in different places.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use g_hasenv

@luhenry
Copy link
Contributor

luhenry commented Apr 13, 2018

@lewurm if we want to keep this feature for MERP only, then we will just enable it in the same icall as we enable MERP support, no need to create another one.

@alexanderkyte alexanderkyte force-pushed the sigterm_handler branch 4 times, most recently from 80fc8f2 to ccec018 Compare April 17, 2018 04:54
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be TARGET_OSX

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why keeping the exit (1);?

Copy link
Contributor Author

@alexanderkyte alexanderkyte Apr 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without an exit(1), you won't exit?
I think there's a minor API confusion here. mono_chain_signal only calls another signal handler if it's already been registered. There's no other sigterm handler, so if you put a print between the chain signal and the exit call, it fires.

Before chain signal And
After chain signal, before exit

Both fire.

This corresponds to the expected state in add_signal_handler, when previous_sa.sa_flags & SA_SIGINFO is false, and we have no already-registered signal handler to save.

For this to work the way you want it to, where removing exit doesn't make it not exit, you'd need to explicitly register the handler at the start of every run that makes mono exit when sent sigterm. POSIX just defaults to externally killing a process when there's no signal handler, that doesn't mean that there's automatically an observable signal handler for sigterm.

@alexanderkyte alexanderkyte force-pushed the sigterm_handler branch 3 times, most recently from 4fc4407 to 01b3e83 Compare April 17, 2018 17:56
@luhenry
Copy link
Contributor

luhenry commented Apr 18, 2018

It's broken on Android and Windows

@luhenry
Copy link
Contributor

luhenry commented Apr 20, 2018

@monojenkins build Windows x64

@luhenry
Copy link
Contributor

luhenry commented Apr 20, 2018

@monojenkins build Linux x64

@luhenry
Copy link
Contributor

luhenry commented Apr 20, 2018

@monojenkins build Linux AArch64

@luhenry luhenry merged commit 24ef425 into mono:master Apr 20, 2018
@luhenry
Copy link
Contributor

luhenry commented Apr 20, 2018

@monojenkins backport to 2018-02

@luhenry
Copy link
Contributor

luhenry commented Apr 20, 2018

@monojenkins backport to 2018-04

@monojenkins
Copy link
Contributor

@luhenry backporting to 2018-02 failed, the patch results in conflicts:

Applying: [runtime] Add a signal handler for sigterm
Applying: [runtime] Register sigtramp when merp handler enabled
Using index info to reconstruct a base tree...
M	mono/metadata/icall.c
M	mono/metadata/object-internals.h
M	mono/mini/mini-posix.c
M	mono/mini/mini-runtime.c
M	mono/mini/mini-runtime.h
Falling back to patching base and 3-way merge...
Auto-merging mono/mini/mini-runtime.h
CONFLICT (content): Merge conflict in mono/mini/mini-runtime.h
Auto-merging mono/mini/mini-runtime.c
Auto-merging mono/mini/mini-posix.c
Auto-merging mono/metadata/object-internals.h
Auto-merging mono/metadata/icall.c
error: Failed to merge in the changes.
Patch failed at 0002 [runtime] Register sigtramp when merp handler enabled

Please backport manually!

@monojenkins
Copy link
Contributor

@luhenry backporting to 2018-04 failed, the patch results in conflicts:

Applying: [runtime] Add a signal handler for sigterm
Applying: [runtime] Register sigtramp when merp handler enabled
Using index info to reconstruct a base tree...
M	mono/metadata/icall.c
M	mono/mini/mini-runtime.c
M	mono/mini/mini-runtime.h
Falling back to patching base and 3-way merge...
Auto-merging mono/mini/mini-runtime.h
CONFLICT (content): Merge conflict in mono/mini/mini-runtime.h
Auto-merging mono/mini/mini-runtime.c
Auto-merging mono/metadata/icall.c
error: Failed to merge in the changes.
Patch failed at 0002 [runtime] Register sigtramp when merp handler enabled

Please backport manually!

picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
* [runtime] Add a signal handler for sigterm

* [runtime] Register sigtramp when merp handler enabled

* [runtime] Limit sigterm handler symbol definition to OSX


Commit migrated from mono/mono@24ef425
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.

8 participants