Skip to content

Conversation

@Physic69
Copy link
Contributor

The title is what it was supposed to do.
The pid needs to be conditional and have to improved
the send_sig is better than what i used

The pid needs to be conditional and have to improved
@Physic69 Physic69 marked this pull request as draft June 18, 2025 14:13
Physic69 added 3 commits June 19, 2025 16:38
added new functions, (needs few improvements as well)
need to add flush_signals functions as well
@Physic69 Physic69 marked this pull request as ready for review June 19, 2025 20:03
@Physic69 Physic69 changed the title Update luathread.c, Add signal() method to luathread: allow Lua to send signals to kernel threads allow Lua to send signals to kernel threads Jun 19, 2025
@Physic69 Physic69 marked this pull request as draft June 20, 2025 17:57
Physic69 added 2 commits June 30, 2025 15:25
add block() -- blocks given signal
minor updates
added enum for signals...
--empty
@Physic69

This comment was marked as resolved.

@Physic69 Physic69 marked this pull request as ready for review July 2, 2025 20:57

int signum = luaL_checkinteger(L, 2);

spin_lock_irq(&task->sighand->siglock);
Copy link
Contributor

Choose a reason for hiding this comment

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

is this lock really necessary? can you point to from where you get this pattern?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Linux/signal.c

This lock prevents race condition between concurrent signal senders (we can say signal masks) {safety :)}

Copy link
Contributor

Choose a reason for hiding this comment

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

my impression is that it should be done internally by signal API, not by its clients.. can you point to some API client doing this?

Copy link
Contributor Author

@Physic69 Physic69 Jul 3, 2025

Choose a reason for hiding this comment

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

flush_signals
The above function is a API client used by us to flush and pending signals and takes lock manually before manipulating them
Sorry for taking too much of time to respond,
I was searching for other examples...

Copy link
Contributor

Choose a reason for hiding this comment

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

it's the internal API implementation.. I meant a client from this API.. I think you are mixing the internal implementation with the API usage..

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm.. I see the problem, you want to allow/block a signal on a specific task.. I think we shouldn't go to this path.. the common pattern as I see is to allow/block signal in the current task.. so such functions would probably belong to lualinux functions and not to luathread methods

Copy link
Contributor Author

@Physic69 Physic69 Jul 4, 2025

Choose a reason for hiding this comment

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

that makes sense now.
You are right, I was trying to manipulate signals on a specific task,
ok ill move these into Lualinux . instead and stick to using the standard allow_signal() API for the current task.
Ill make a new updated PR for that, Shall I close this one?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you still need send() and pending(), right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you're right. I’ll check once send() and pending() in threads to make sure everything is good.
For now, I’ll go ahead
and move allow(), isallowed() and block() to lualinux
I’ll update everything properly and move on from there. Sounds good?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yup.. thanks!

return luaL_error(L, "thread task is NULL");

int signum = luaL_checkinteger(L, 2);
if (sigismember(&task->blocked, signum))
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need this? can you provide some documentation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we dont check before sending signal, the blocked signal wont be handled properly, it will be queued. This is what I remember. I will add the source as well (have to look where I read this )

Copy link
Contributor

Choose a reason for hiding this comment

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

wasn't it expected? why shouldn't it be queued?

Copy link
Contributor Author

@Physic69 Physic69 Jul 3, 2025

Choose a reason for hiding this comment

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

my bad, we don't need to check this here. Thanks for pointing this out. I mixed two different concepts here 😅,
I just checked the official docs. This is required in synchronous signals, which we are not doing. I'll update it soon

@Physic69 Physic69 marked this pull request as draft July 3, 2025 18:22
@lneto lneto force-pushed the master branch 2 times, most recently from 17ac113 to 925bfd9 Compare July 14, 2025 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants