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

Implement os.SIGDFL and os.SIGIGN #4895

Closed
wants to merge 1 commit into from

Conversation

dkaszews
Copy link
Contributor

@dkaszews dkaszews commented Mar 28, 2024

Fixes: #4889

Allows user to reset the previously overwritten os.signal or ignore it completely (not passed to process, same as with { exclusive = true }.

Opens:

  • More descriptive names like signal_default/reset and signal_ignore instead of Unix's SIGDFL and SIGIGN?
  • Tests? May be tricky to test signals, would need to run xmake in a subprocess of its own.
  • Add documentation

@waruqi
Copy link
Member

waruqi commented Mar 29, 2024

More descriptive names like signal_default/reset and signal_ignore instead of Unix's SIGDFL and SIGIGN?

or we can use

os.signal(os.SIGINT, {reset = true})
os.signal(os.SIGINT, {ignore = true})

@waruqi
Copy link
Member

waruqi commented Mar 29, 2024

Tests? May be tricky to test signals, would need to run xmake in a subprocess of its own.

If you can help to add some tests, it will be better.

@waruqi
Copy link
Member

waruqi commented Mar 29, 2024

@waruqi waruqi added this to the v2.9.1 milestone Mar 29, 2024
@dkaszews
Copy link
Contributor Author

os.signal(os.SIGINT, {reset = true})
os.signal(os.SIGINT, {ignore = true})

I don't quite like using dictionary just for named value, it's easy to make a typo and not get any feedback. I think cleaner would be to create one function for each:

name signal xmake action process signalled
os.set_signal(signo, fun) fun callback yes
os.ignore_signal(signo) SIG_IGN no action no
os.reset_signal(signo) SIG_DLF killed yes(1)

Notes:

  1. If traps and does not exit, then it's orphaned detached from I/O as per issue

@waruqi
Copy link
Member

waruqi commented Mar 30, 2024

I wouldn't consider adding too much API to the os module for signal. please only use os.signal

Or use a separate signal module.

signal.register(signo, handler)
signal.ignore(signo)
signal.reset(signo)

@dkaszews
Copy link
Contributor Author

Or use a separate signal module.

Understood, how about putting it in process since it's related and has relatively small API?

@waruqi
Copy link
Member

waruqi commented Mar 30, 2024

Or use a separate signal module.

Understood, how about putting it in since it's related and has relatively small API?process

no, process is only used to run and manage a single child process.

@waruqi waruqi mentioned this pull request Mar 31, 2024
@waruqi
Copy link
Member

waruqi commented Mar 31, 2024

see #4908

@waruqi waruqi closed this Mar 31, 2024
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.

2 participants