Return-Path: X-Original-To: apmail-mesos-issues-archive@minotaur.apache.org Delivered-To: apmail-mesos-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 666F717AFF for ; Tue, 7 Apr 2015 10:25:28 +0000 (UTC) Received: (qmail 89950 invoked by uid 500); 7 Apr 2015 10:25:12 -0000 Delivered-To: apmail-mesos-issues-archive@mesos.apache.org Received: (qmail 89922 invoked by uid 500); 7 Apr 2015 10:25:12 -0000 Mailing-List: contact issues-help@mesos.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@mesos.apache.org Delivered-To: mailing list issues@mesos.apache.org Received: (qmail 89912 invoked by uid 99); 7 Apr 2015 10:25:12 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Apr 2015 10:25:12 +0000 Date: Tue, 7 Apr 2015 10:25:12 +0000 (UTC) From: "Adam B (JIRA)" To: issues@mesos.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (MESOS-1102) Further extensions to process::subprocess MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/MESOS-1102?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14482954#comment-14482954 ] Adam B commented on MESOS-1102: ------------------------------- [~tillt] Perhaps you'd like to create new finer-grained tickets for the other improvements you suggested. > Further extensions to process::subprocess > ----------------------------------------- > > Key: MESOS-1102 > URL: https://issues.apache.org/jira/browse/MESOS-1102 > Project: Mesos > Issue Type: Improvement > Components: libprocess > Affects Versions: 0.19.0 > Reporter: Till Toenshoff > Assignee: Till Toenshoff > Priority: Minor > Labels: libprocess, subprocess > > I would like to propose the addition of a way to run a function within the forked child context to process::subprocess. > The subprocess implementation is already extremely valuable and will allow us to remove many scattered, similar implementations within mesos once it is flexible enough. > The recent addition (in review) of adding an environment map is just the right step into that direction. > However, there still are areas, mostly within containerizer specifics that can not be replaced by the subprocess implementation as is, IMHO because running a function in the child context is missing. See e.g. /src/slave/containerizer/launcher.cpp, /src/slave/containerizer/mesos_containerizer.cpp and last but not least the pluggable_containerizer (in review). > My envisioned approach would look something like this: > {noformat} > // Runs the provided command in a subprocess. > // NOTE: Take extra care about the design of the inChild > // lambda as it must not contain any async unsafe code. > Try subprocess( > const std::string& command, > const std::map& env = std::map(), > const lambda::function& inChild = NULL); > {noformat} > Example usage: > {noformat} > struct ChildFunction { > ChildFunction(const string& directory) : directory(directory) {}; > void operator ()() > { > if (::chdir(directory) < 0) { > ABORT("Failed to chdir"); > } > } > const string& directory; > }; > Try external = subprocess( > "foo", > map(), > ChildFunction("bar"); > {noformat} > Please let me know what you think about this or if I was on a wrong track. -- This message was sent by Atlassian JIRA (v6.3.4#6332)