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

libsubprocess: update read/write functions to be more like read(2) and write(2) #5953

Closed
chu11 opened this issue May 9, 2024 · 0 comments
Closed
Assignees

Comments

@chu11
Copy link
Member

chu11 commented May 9, 2024

Per comment in #5940, a number of the libsubprocess API functions are a little odd in that they return a pointer to a buffer rather than an int. This is b/c they were designed following the flux buffer (i.e. now fbuf) api. Make them more read(2) and write(2) like ...

ssize_t flux_subprocess_read (flux_subprocess_t *p, const char *stream, const void **buf);

@chu11 chu11 self-assigned this May 13, 2024
chu11 added a commit to chu11/flux-core that referenced this issue May 13, 2024
Problem: The flux_subprocess_read() family of functions
return a ptr to a buffer on success and length of buffer in an
optional parameter.

This API style isn't the most intuitive as it is quite different
than the read(2) system call.  Most notably when EOF
is reached on a read stream you have to check if the buffer pointer
is non-NULL and the length returned from an optional parameter
is 0.

Solution:  Update the read family of functions to return the
length from the function and the buffer pointer in an optional parameter.

Update all callers accordingly.

Fixes flux-framework#5953
chu11 added a commit to chu11/flux-core that referenced this issue May 13, 2024
Problem: The flux_subprocess_read() family of functions
return a ptr to a buffer on success and length of buffer in an
optional parameter.

This API style isn't the most intuitive as it is quite different
than the read(2) system call.  Most notably when EOF
is reached on a read stream you have to check if the buffer pointer
is non-NULL and the length returned from an optional parameter
is 0.

Solution:  Update the read family of functions to return the
length from the function and the buffer pointer in an optional parameter.

Update all callers accordingly.

Fixes flux-framework#5953
chu11 added a commit to chu11/flux-core that referenced this issue May 13, 2024
Problem: The flux_subprocess_read() family of functions
return a pointer to a buffer on success and length of buffer in an
optional parameter.

This API style isn't the most intuitive as it is quite different
than the read(2) system call.  Most notably when EOF
is reached on a read stream you have to check if the buffer pointer
is non-NULL and the length returned from an optional parameter
is 0.

Solution:  Update the read family of functions to return the
length from the function and the buffer pointer in an optional parameter.

Update all callers accordingly.

Fixes flux-framework#5953
chu11 added a commit to chu11/flux-core that referenced this issue May 14, 2024
Problem: The flux_subprocess_read() family of functions
return a pointer to a buffer on success and length of buffer in an
optional parameter.

This API style isn't the most intuitive as it is quite different
than the read(2) system call.  Most notably when EOF
is reached on a read stream you have to check if the buffer pointer
is non-NULL and the length returned from an optional parameter
is 0.

Solution:  Update the read family of functions to return the
length from the function and the buffer pointer in an optional parameter.

Update all callers accordingly.

Fixes flux-framework#5953
chu11 added a commit to chu11/flux-core that referenced this issue May 14, 2024
Problem: The flux_subprocess_read() family of functions
return a pointer to a buffer on success and length of buffer in an
optional parameter.

This API style isn't the most intuitive as it is quite different
than the read(2) system call.  Most notably when EOF
is reached on a read stream you have to check if the buffer pointer
is non-NULL and the length returned from an optional parameter
is 0.

Solution:  Update the read family of functions to return the
length from the function and the buffer pointer in an optional parameter.

Update all callers accordingly.

Fixes flux-framework#5953
chu11 added a commit to chu11/flux-core that referenced this issue May 16, 2024
Problem: The flux_subprocess_read() family of functions
return a pointer to a buffer on success and length of buffer in an
optional parameter.

This API style isn't the most intuitive as it is quite different
than the read(2) system call.  Most notably when EOF
is reached on a read stream you have to check if the buffer pointer
is non-NULL and the length returned from an optional parameter
is 0.

Solution: Update the read family of functions to return the
length from the function and the buffer pointer in an optional parameter.

Update all callers accordingly.

Fixes flux-framework#5953
@mergify mergify bot closed this as completed in c436b85 May 16, 2024
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

No branches or pull requests

1 participant