-
Notifications
You must be signed in to change notification settings - Fork 191
feat: send_signal
subroutine in system module
#947
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
Conversation
Thank you for your contribution @wassup05. I appreciate the effort in expanding the process module. I have some concerns regarding the inclusion of a
Looking forward to hearing your thoughts as well as those of the other maintainers, @jalvesz @jvdp1? |
Thank you @perazz for your reply, Here is what I think about the concerns you have raised
|
Thanks @wassup05 for this PR, I have not much experience with low level signal management, so I will refrain from giving opinions on the technical aspect. I agree with @perazz regarding the fact that stdlib tries as hard as possible to be agnostic to the platform and to propose an unified API for all users. So this should be kept in mind as much as possible. Non cross-platforms APIs should be the exception. I do see an interest in the last point mentioned by @wassup05. I would advise that this debate is opened at discourse following a similar spirit as the thread opened by @perazz here https://fortran-lang.discourse.group/t/stdlib-system-interaction-api-call-for-feedback/9037 in order to collect the opinions of the wider community. |
To add to the discussion, here is two prototype subroutine signatures that I think would be viable for ! Send SIGINT or equivalent in Windows
subroutine interrupt(process)
type(process_type), intent(inout) :: process
end subroutine interrupt
! Send SIGTERM or equivalent on Windows
subroutine terminate(process)
type(process_type), intent(inout) :: process
end subroutine terminate Let me stress that cross-platform functionality would be a necessary feature imho. |
On Discourse I have posted a C example (shamelessly taken from Wikipedia)
that can be built on Windows with gcc, cl and icx. All resulting programs
produce the same output. One caveat: it seems that the C API that is used
is not the recommended one, but the newer one is much more complicated and
it may not be worth the effort.
Op wo 12 mrt 2025 om 08:15 schreef Federico Perini ***@***.***
…:
To add to the discussion, here is two prototype subroutine signatures that
I think would be viable for stdlib, and that are in line with the current
kill API:
! Send SIGINT or equivalent in Windows
subroutine interrupt(process)
type(process_type), intent(inout) :: process
end subroutine interrupt
! Send SIGTERM or equivalent on Windows
subroutine terminate(process)
type(process_type), intent(inout) :: process
end subroutine terminate
Let me stress that cross-platform functionality would be a necessary
feature imho.
—
Reply to this email directly, view it on GitHub
<#947 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAN6YR7GHPTVL6KTOATIKR32T7NKDAVCNFSM6AAAAABYSPWS66VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMJWHAZTKMZRGU>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
[image: perazz]*perazz* left a comment (fortran-lang/stdlib#947)
<#947 (comment)>
To add to the discussion, here is two prototype subroutine signatures that
I think would be viable for stdlib, and that are in line with the current
kill API:
! Send SIGINT or equivalent in Windows
subroutine interrupt(process)
type(process_type), intent(inout) :: process
end subroutine interrupt
! Send SIGTERM or equivalent on Windows
subroutine terminate(process)
type(process_type), intent(inout) :: process
end subroutine terminate
Let me stress that cross-platform functionality would be a necessary
feature imho.
—
Reply to this email directly, view it on GitHub
<#947 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAN6YR7GHPTVL6KTOATIKR32T7NKDAVCNFSM6AAAAABYSPWS66VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMJWHAZTKMZRGU>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
@perazz I agree that this indeed is a good option but I think there will be some problems on the Windows side, because generating a
|
Thanks for the comments @wassup05. Imho this would be a limiting factor for a Fortran library that strives to be system-agnostic. I would be happy to see possible solutions that would make this work also on Windows OSses. |
I realised I missed a crucial point while thinking about this (I am sorry)... on the C side you could send signals to random So I was thinking, Or as suggested by @perazz, just Which one do you think is a good idea? If at all you deem this is a useful and worthwhile functionality to have in the |
I have never used signals beyond SIGKILL and SIGTERM (to kill a process on
Linux/UNIX - "kill -15 pid" or "kill -9 pid" if the first did not work). I
think it would be useful to have at least a minimal functionality like
that, together with SIGINT. I would prefer a set of signals that can be
supported on all relevant platforms with the same meaning. If that is too
limiting, then at least reasonable acrtions for those signals that are not
supported.
Op di 18 mrt 2025 om 15:03 schreef Suprit S J ***@***.***>:
… I realised I missed a crucial point while thinking about this (I am
sorry)... on the C side you could send signals to random pid but because
of the type process here, there are limitations.. you must have created
the process using the same process variable... which simplifies stuff on
the windows side because these are indeed attached to the same console
So I was thinking, send_signal could do the usual on unix like systems
(i.e send the requested signal) but on windows side if the signal is
SIGINT we could send a CTRL_C_EVENT or CTRL_BREAK_EVENT and if it is
SIGTERM we could send CTRL_CLOSE_EVENT and if any other signal is
provided, since there are no equivalent on Windows we could just try to
Terminate the Process.... hence providing alternatives to both kinds of
users
Or as suggested by @perazz <https://github.com/perazz>, just interrupt
and terminate also can be a good option (maybe compromising the needs of
unix users a bit)
Which one do you think is a good idea? If at all you deem this is a useful
and worthwhile functionality to have in the system module (I would like
honest remarks on this too!)
@perazz <https://github.com/perazz> @jalvesz <https://github.com/jalvesz>
@arjenmarkus <https://github.com/arjenmarkus>
—
Reply to this email directly, view it on GitHub
<#947 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAN6YRYN6XNCTHPK4JR5BQ32VARUFAVCNFSM6AAAAABYSPWS66VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMZTGM3TMMJXG4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
[image: wassup05]*wassup05* left a comment (fortran-lang/stdlib#947)
<#947 (comment)>
I realised I missed a crucial point while thinking about this (I am
sorry)... on the C side you could send signals to random pid but because
of the type process here, there are limitations.. you must have created
the process using the same process variable... which simplifies stuff on
the windows side because these are indeed attached to the same console
So I was thinking, send_signal could do the usual on unix like systems
(i.e send the requested signal) but on windows side if the signal is
SIGINT we could send a CTRL_C_EVENT or CTRL_BREAK_EVENT and if it is
SIGTERM we could send CTRL_CLOSE_EVENT and if any other signal is
provided, since there are no equivalent on Windows we could just try to
Terminate the Process.... hence providing alternatives to both kinds of
users
Or as suggested by @perazz <https://github.com/perazz>, just interrupt
and terminate also can be a good option (maybe compromising the needs of
unix users a bit)
Which one do you think is a good idea? If at all you deem this is a useful
and worthwhile functionality to have in the system module (I would like
honest remarks on this too!)
@perazz <https://github.com/perazz> @jalvesz <https://github.com/jalvesz>
@arjenmarkus <https://github.com/arjenmarkus>
—
Reply to this email directly, view it on GitHub
<#947 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAN6YRYN6XNCTHPK4JR5BQ32VARUFAVCNFSM6AAAAABYSPWS66VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMZTGM3TMMJXG4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I tend to agree with @arjenmarkus. My opinion is that the practical way to implement that is to have two more functions |
Okay thank you @perazz and @arjenmarkus for your suggestions. I will make another PR regarding the same and close this as this is no longer necessary. |
This PR proposes a
send_signal
subroutine to thesystem
module.kill
subroutine does the job)signal
as aninteger
argument representing the signal numbersuccess
which is true if all went well and false if some errors ocurredprocess
object