Skip to content

Fix(system_subprocess): save_completed_state passing stderr instead of stdin to callback#1159

Open
Mahmood-Sinan wants to merge 3 commits intofortran-lang:masterfrom
Mahmood-Sinan:system_run_sync_arg_error
Open

Fix(system_subprocess): save_completed_state passing stderr instead of stdin to callback#1159
Mahmood-Sinan wants to merge 3 commits intofortran-lang:masterfrom
Mahmood-Sinan:system_run_sync_arg_error

Conversation

@Mahmood-Sinan
Copy link
Copy Markdown
Contributor

Fixes incorrect argument mapping in process_callback inside save_completed_state subroutine where process%stderr was passed twice, causing stdin to be omitted. In one place process%stderr was being passed in place of process%stdin. This change correctly passes process%stdin.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 26, 2026

Codecov Report

❌ Patch coverage is 96.42857% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 68.74%. Comparing base (ac98d3b) to head (91be530).
⚠️ Report is 28 commits behind head on master.

Files with missing lines Patch % Lines
test/system/test_subprocess.f90 96.42% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1159      +/-   ##
==========================================
+ Coverage   68.00%   68.74%   +0.73%     
==========================================
  Files         404      407       +3     
  Lines       12935    13641     +706     
  Branches     1392     1546     +154     
==========================================
+ Hits         8797     9377     +580     
- Misses       4138     4264     +126     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@perazz perazz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, thank you for fixing that @Mahmood-Sinan. Would it be possible to add a test routine that exercises using stdin with a process completion callback ?

@Mahmood-Sinan
Copy link
Copy Markdown
Contributor Author

Nice catch, thank you for fixing that @Mahmood-Sinan. Would it be possible to add a test routine that exercises using stdin with a process completion callback ?

Thanks for reviewing. I have added the test for callback. I had to use a wrapper for payload because array of character strings were getting converted into a scalar variable in callback subroutine. Please take a look.

Copy link
Copy Markdown
Member

@jvdp1 jvdp1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you @Mahmood-Sinan . Here are a few suggestions

module test_subprocess
use testdrive, only : new_unittest, unittest_type, error_type, check, skip_test
use stdlib_system, only: process_type, run, runasync, is_running, wait, update, elapsed, is_windows, kill
use stdlib_system, only: process_type, run, runasync, is_running, wait, update, elapsed, is_windows, kill, process_ID
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
use stdlib_system, only: process_type, run, runasync, is_running, wait, update, elapsed, is_windows, kill, process_ID
use stdlib_system, only: process_type, run, runasync, is_running, wait, update, elapsed, is_windows, kill, process_id


implicit none

type :: payload_wrapper
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be the DT string_type of stdlib used?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I tried, the compiler gave me an error saying that

  193 |             type is (string_type)
      |                                 1
Error: The type-spec shall not specify a sequence derived type or a type with the BIND attribute in SELECT TYPE at (1) [F2003:C815]

I supposed we cannot do so, since string_type has sequence attribute.

end subroutine test_input_redirection

subroutine test_callback(error)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

end subroutine test_callback

subroutine callback_function(pid, exitcode, stdin, stdout, stderr, payload)
integer(process_ID), intent(in) :: pid
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
integer(process_ID), intent(in) :: pid
integer(process_id), intent(in) :: pid

@Mahmood-Sinan
Copy link
Copy Markdown
Contributor Author

@jvdp1 Thanks for reviewing. I have made the changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants