[Boost-bugs] [Boost C++ Libraries] #13321: boost::process: executable extension is required to create a process.

Subject: [Boost-bugs] [Boost C++ Libraries] #13321: boost::process: executable extension is required to create a process.
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-12-04 11:29:49


#13321: boost::process: executable extension is required to create a process.
--------------------------------------+---------------------
 Reporter: jpo38 <jean.porcherot@…> | Owner: (none)
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: None
  Version: Boost 1.65.0 | Severity: Problem
 Keywords: |
--------------------------------------+---------------------
 The following code does not assert under Windows:

 {{{
 int main( int argc, char* argv[] )
 {
     try
     {
         boost::process::child p( "cmd" );
         p.terminate();
     }
     catch (...)
     {
         assert( false );
     }

     try
     {
         boost::process::child p( "cmd.exe" );
         p.terminate();
     }
     catch (...)
     {
         assert( false );
     }

     return 0;
 }
 }}}

 So, apparently, .exe does not need to be specified.

 However, the following code does assert when .exe is not specified:

 {{{
 int main( int argc, char* argv[] )
 {
     if ( argc == 1 )
     {
         std::string exe = argv[0];
         try
         {
             std::string exeNoExt = exe.substr(0, exe.find_last_of("."));
             boost::process::child p( exeNoExt, "foo" );
             p.terminate();
         }
         catch (...)
         {
             assert( false ); // asserts
         }

         try
         {
             boost::process::child p( exe, "foo" );
             p.terminate();
         }
         catch (...)
         {
             assert( false ); // does not assert
         }
     }
 }}}

 boost::process::child p( exeNoExt, "foo" ); should work and executable
 extention should be silently added, like it is for cmd.

 Note that boost::process::search_path( "myprg" ) returns "myprg.exe" if
 found, so here, extension is added correctly. But it's unsafe to
 systematically call this function priori to creating a child as it only
 works with program names (calling it with "Myfolder/myprg" returns "").

-- 
Ticket URL: <https://svn.boost.org/trac10/boost/ticket/13321>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-12-04 11:36:24 UTC