Skip to content
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

system: subprocessing interface #911

Merged
merged 60 commits into from
Feb 25, 2025
Merged
Changes from 1 commit
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
979ba84
add c source
perazz Dec 24, 2024
79ddfc4
add subprocess module
perazz Dec 24, 2024
adacbcf
`to_c_string`: move to strings, document
perazz Dec 24, 2024
5b543a2
use temporary `getfile` and `linalg_state_type` f
perazz Dec 24, 2024
519d53d
implement `join`
perazz Dec 24, 2024
1449b8d
fixes to build
perazz Dec 24, 2024
cf35194
create submodule
perazz Dec 24, 2024
e8451b2
unify `sleep` interface
perazz Dec 24, 2024
48da380
add single-command `run` API
perazz Dec 24, 2024
1f4de32
add tests
perazz Dec 24, 2024
6fbc2e6
getfile: remove trailing new line characters
perazz Dec 24, 2024
f9bf304
fix tests to be cross-platform
perazz Dec 24, 2024
71facb3
use `nanosleep` rather than `usleep`
perazz Dec 24, 2024
6ea72d1
add examples
perazz Dec 24, 2024
e35b37a
`kill` process
perazz Dec 24, 2024
237e9ff
add process killing example
perazz Dec 24, 2024
2c58fca
on Windows, redirect to `NUL` if output not requested
perazz Dec 24, 2024
136b5b8
remove unused process handle
perazz Dec 25, 2024
d8df028
document `run` interface
perazz Dec 25, 2024
94f2bdf
document `is_running`, `is_completed`, `elapsed`
perazz Dec 25, 2024
3fb88e4
add `system` page
perazz Dec 25, 2024
53fc8e5
document `wait`
perazz Dec 25, 2024
b30cae4
document `update`
perazz Dec 25, 2024
122fbc6
document `kill`
perazz Dec 25, 2024
56ed7c8
document `sleep`
perazz Dec 25, 2024
c617048
document `has_win32`
perazz Dec 25, 2024
ed0565c
fix
perazz Dec 25, 2024
c03655a
Merge branch 'subprocess' of github.com:perazz/stdlib into subprocess
perazz Dec 26, 2024
eb77455
Merge branch 'fortran-lang:master' into subprocess
perazz Dec 26, 2024
74b6ebe
change syntax for `ifx` fix
perazz Dec 26, 2024
9873bc9
fix `sleep` us -> ns
perazz Dec 26, 2024
34732ff
fix `pid` size
perazz Dec 26, 2024
53b03b0
full-cmd: do not use stack
perazz Dec 26, 2024
5a1bd54
fix `sleep`
perazz Dec 26, 2024
9b74bea
process example 2: set max_wait_time
perazz Dec 26, 2024
bdb2840
sleep: fix `bind(C)` interface
perazz Dec 26, 2024
a1aaf2f
split `run` vs `runasync`
perazz Jan 28, 2025
4d5eb32
`run/runasync` docs
perazz Jan 28, 2025
56f02ab
`has_win32` -> `is_windows`
perazz Jan 28, 2025
15689bc
Update example_process_1.f90
perazz Jan 28, 2025
060dec7
Merge branch 'master' into subprocess
perazz Jan 28, 2025
3560a6f
missing `is_windows` tests
perazz Jan 28, 2025
e75bbc9
Merge branch 'subprocess' of github.com:perazz/stdlib into subprocess
perazz Jan 28, 2025
d1a4715
Update example_process_4.f90
perazz Jan 28, 2025
68dca8d
Merge branch 'fortran-lang:master' into subprocess
perazz Jan 29, 2025
7653cc4
add object oriented interface
perazz Feb 4, 2025
06c7136
add oop example
perazz Feb 4, 2025
f40a547
process ID (`pid`) getter interface
perazz Feb 4, 2025
d2ee2f2
implement callback
perazz Feb 4, 2025
3f08a8b
add callback example
perazz Feb 4, 2025
d694dcf
fix submodule
perazz Feb 4, 2025
80a2d0a
intel fix: no inline type
perazz Feb 4, 2025
20c045d
document callback and payload functionality
perazz Feb 4, 2025
bb98188
Merge branch 'master' into subprocess
perazz Feb 17, 2025
33f81a3
`to_c_string` -> `to_c_char`
perazz Feb 17, 2025
d8f8be7
Merge branch 'subprocess' of https://github.com/perazz/stdlib into su…
perazz Feb 17, 2025
deabd0c
Update doc/specs/stdlib_system.md
perazz Feb 17, 2025
f55ddb7
Update doc/specs/stdlib_system.md
perazz Feb 17, 2025
d4422cf
move all examples to separate files
perazz Feb 17, 2025
0675b8c
Merge branch 'subprocess' of https://github.com/perazz/stdlib into su…
perazz Feb 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update example_process_1.f90
perazz committed Jan 28, 2025
commit 15689bc2f7a361260f5f2e07b20bc212413b4e39
8 changes: 6 additions & 2 deletions example/system/example_process_1.f90
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
! Process example 1: Run a Command Synchronously and Capture Output
program run_sync
use stdlib_system, only: run, is_completed, process_type
use stdlib_system, only: run, is_completed, is_windows, process_type
implicit none

type(process_type) :: p
logical :: completed

! Run a synchronous process to list directory contents
p = run("ls -l", want_stdout=.true.)
if (is_windows()) then
p = run("dir", want_stdout=.true.)
else
p = run("ls -l", want_stdout=.true.)
end if

! Check if the process is completed (should be true since wait=.true.)
if (is_completed(p)) then