File: example_process_7.f90

package info (click to toggle)
fortran-stdlib 0.8.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 34,008 kB
  • sloc: f90: 24,178; ansic: 1,244; cpp: 623; python: 119; makefile: 13
file content (21 lines) | stat: -rw-r--r-- 496 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
! Process example 7: Usage of `kill`
program example_process_7
    use stdlib_system, only: process_type, runasync, kill
    implicit none

    type(process_type) :: p
    logical :: success

    ! Start a process asynchronously
    p = runasync("sleep 10")

    ! Attempt to kill the process
    call kill(p, success)

    if (success) then
        print *, "Process successfully killed."
    else
        print *, "Failed to kill the process."
    end if
    
end program example_process_7