File: example_process_2.f90

package info (click to toggle)
fortran-stdlib 0.8.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, 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-- 608 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 2: Run an Asynchronous Command and check its status
program run_async
    use stdlib_system, only: process_type, runasync, is_running, wait
    implicit none

    type(process_type) :: p

    ! Run an asynchronous process to sleep for 1 second
    p = runasync("sleep 1")

    ! Check if the process is running
    if (is_running(p)) then
        print *, "Process is running."
    else
        print *, "Process has already completed."
    end if

    ! Wait for the process to complete
    call wait(p, max_wait_time = 5.0)
    print *, "Process has now completed."
end program run_async