You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@mesos.apache.org by "Andrew Schwartzmeyer (JIRA)" <ji...@apache.org> on 2018/03/06 23:32:00 UTC
[jira] [Comment Edited] (MESOS-4549) Consider returning `Try` for
`os::system`.
[ https://issues.apache.org/jira/browse/MESOS-4549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16388704#comment-16388704 ]
Andrew Schwartzmeyer edited comment on MESOS-4549 at 3/6/18 11:31 PM:
----------------------------------------------------------------------
As of
commit 330ddcb51
Author: Akash Gupta akash-gupta@hotmail.com
Date: Tue Mar 6 13:11:21 2018 -0800
Changed `os::system()` to return `Option<int>` instead of `int`.
The `os::system()` function returned `-1` on error, which is a valid
exit code on Windows, e.g., `os::system("exit -1")`, so it was
impossible to distinguish a failure from a process returning `-1`.
With `Option<int>`, failures will return as `None()`.
Review: https://reviews.apache.org/r/65841/
{{os::system}} now returns an {{Option<int>}}, as {{Try}} isn't usable since it uses {{std::string}} for {{Error}}, which isn't async signal safe.
This can be trivially converted to a {{Try}} if we believe the underlying {{Error}} in the {{Try}} is safe enough.
was (Author: andschwa):
As of
commit 330ddcb51
Author: Akash Gupta akash-gupta@hotmail.com
Date: Tue Mar 6 13:11:21 2018 -0800
Changed `os::system()` to return `Option<int>` instead of `int`.
The `os::system()` function returned `-1` on error, which is a valid
exit code on Windows, e.g., `os::system("exit -1")`, so it was
impossible to distinguish a failure from a process returning `-1`.
With `Option<int>`, failures will return as `None()`.
Review: https://reviews.apache.org/r/65841/
{{os::system}} now returns an {{Option<int>}}, as {{Try}} isn't usable since it uses {{std::string}} for {{Error}}, which isn't async signal safe.
> Consider returning `Try` for `os::system`.
> ------------------------------------------
>
> Key: MESOS-4549
> URL: https://issues.apache.org/jira/browse/MESOS-4549
> Project: Mesos
> Issue Type: Task
> Components: stout
> Reporter: Michael Park
> Priority: Minor
>
> The {{os::system}} has the following description:
> {code}
> // Executes a command by calling "/bin/sh -c <command>", and returns
> // after the command has been completed. Returns 0 if succeeds, and
> // return -1 on error (e.g., fork/exec/waitpid failed). This function
> // is async signal safe. We return int instead of returning a Try
> // because Try involves 'new', which is not async signal safe.
> inline int system(const std::string& command);
> {code}
> Since {{Try}} no longer involves dynamic allocations, we can reconsider returning a {{Try}} out of this function.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)