@@ -43,6 +43,13 @@ logical(c_bool) function process_system_kill(pid) bind(C, name='process_kill')
43
43
implicit none
44
44
integer (process_ID), intent (in ), value :: pid
45
45
end function process_system_kill
46
+
47
+ logical (c_bool) function process_system_send_signal(pid, signal) bind(C, name= ' process_send_signal' )
48
+ import c_bool, process_ID
49
+ implicit none
50
+ integer (process_ID), intent (in ), value :: pid
51
+ integer , intent (in ), value :: signal
52
+ end function process_system_send_signal
46
53
47
54
! System implementation of a wait function
48
55
subroutine process_wait (seconds ) bind(C,name= ' process_wait' )
@@ -473,6 +480,40 @@ module subroutine process_kill(process, success)
473
480
end if
474
481
475
482
end subroutine process_kill
483
+
484
+ ! Send POSIX signal to a process
485
+ module subroutine process_send_signal (process , signal , success )
486
+ class(process_type), intent (inout ) :: process
487
+ ! Signal number
488
+ integer , intent (in ) :: signal
489
+ ! Return a boolean flag for successful operation
490
+ logical , intent (out ) :: success
491
+
492
+ integer (c_int) :: exit_code
493
+ logical (c_bool) :: running
494
+
495
+ success = .true.
496
+
497
+ ! No need to
498
+ if (process% completed) return
499
+ if (process% id == FORKED_PROCESS) return
500
+
501
+ success = logical (process_system_send_signal(process% id, signal))
502
+
503
+ if (success) then
504
+
505
+ call process_query_status(process% id, wait= C_FALSE, is_running= running, exit_code= exit_code)
506
+ process% completed = .not. running
507
+
508
+ if (process% completed) then
509
+ ! Process completed, may have returned an error code
510
+ process% exit_code = exit_code
511
+ call save_completed_state(process,delete_files= .true. )
512
+ end if
513
+
514
+ end if
515
+
516
+ end subroutine process_send_signal
476
517
477
518
subroutine save_completed_state (process ,delete_files )
478
519
class(process_type), intent (inout ) :: process
0 commit comments