GFC Logo GFC Title Logo
Reference Manual
Main Page  |  Namespace List  |  Alphabetical List  |  Class List  |  File List

spawn.hh

Go to the documentation of this file.
00001 /* GFC-Core: GTK+ Foundation Classes (Core Library) 00002 * Copyright (C) 2003 The GFC Development Team. 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU Library General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Library General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 */ 00018 00021 00022 #ifndef GFC_G_SPAWN_HH 00023 #define GFC_G_SPAWN_HH 00024 00025 #ifndef GFC_STACK_OBJECT_HH 00026 #include <gfc/stackobject.hh> 00027 #endif 00028 00029 #ifndef SIGCXX_SIGCXX_H 00030 #include <sigc++/sigc++.h> 00031 #endif 00032 00033 #ifndef __G_SPAWN_H__ 00034 #include <glib/gspawn.h> 00035 #endif 00036 00037 #ifndef _CPP_VECTOR 00038 #include <vector> 00039 #endif 00040 00041 namespace GFC { 00042 00043 namespace G { 00044 00045 class Error; 00046 class SpawnData; 00047 class SpawnSyncData; 00048 00051 00052 enum SpawnFlags 00053 { 00054 SPAWN_LEAVE_DESCRIPTORS_OPEN = G_SPAWN_LEAVE_DESCRIPTORS_OPEN, 00058 00059 SPAWN_DO_NOT_REAP_CHILD = G_SPAWN_DO_NOT_REAP_CHILD, 00062 00063 SPAWN_SEARCH_PATH = G_SPAWN_SEARCH_PATH, 00065 00066 SPAWN_STDOUT_TO_DEV_NULL = G_SPAWN_STDOUT_TO_DEV_NULL, 00069 00070 SPAWN_STDERR_TO_DEV_NULL = G_SPAWN_STDERR_TO_DEV_NULL, 00072 00073 SPAWN_CHILD_INHERITS_STDIN = G_SPAWN_CHILD_INHERITS_STDIN, 00076 00077 SPAWN_FILE_AND_ARGV_ZERO = G_SPAWN_FILE_AND_ARGV_ZERO 00081 }; 00082 00084 00085 typedef unsigned int SpawnFlagsField; 00086 00089 00090 struct SpawnAsyncData 00091 { 00092 GPid child_pid; 00093 }; 00094 00112 00113 class Spawn : public StackObject, protected sigc::trackable 00114 { 00115 Spawn(const Spawn&); 00116 Spawn& operator=(const Spawn&); 00117 00118 SpawnData *data_; 00119 00120 protected: 00123 00124 Spawn(const std::vector<std::string>& argv, SpawnFlagsField flags); 00129 00130 Spawn(const std::string& command_line, G::Error *error); 00136 00137 ~Spawn(); 00139 00143 00144 const char* get_working_directory() const; 00146 00147 char** get_argv() const; 00149 00150 char** get_envp() const; 00152 00153 GSpawnFlags get_flags() const; 00155 00157 00158 public: 00159 typedef sigc::slot<void> ChildSetupSlot; 00170 00173 00174 void set_working_directory(const std::string& working_directory); 00179 00180 void set_enviroment(std::vector<std::string>& envp); 00187 00189 00190 static void close_pid(GPid pid); 00198 00199 }; 00200 00281 00282 class SpawnAsync : public Spawn 00283 { 00284 SpawnAsync(const SpawnAsync&); 00285 SpawnAsync& operator=(const SpawnAsync&); 00286 00287 SpawnAsyncData *data_; 00288 00289 public: 00292 00293 SpawnAsync(const std::vector<std::string>& argv, SpawnFlagsField flags = 0); 00302 00303 SpawnAsync(const std::string& command_line, G::Error *error); 00315 00316 ~SpawnAsync(); 00318 00322 00323 GPid child_pid() const; 00326 00330 00331 bool execute(G::Error *error = 0); 00336 00337 bool execute(const ChildSetupSlot& slot, G::Error *error = 0); 00343 00344 bool execute(const ChildSetupSlot& slot, int *std_input , int *std_output, int *std_error, G::Error *error = 0); 00364 00366 }; 00367 00404 00405 class SpawnSync : public Spawn 00406 { 00407 SpawnSync(const SpawnSync&); 00408 SpawnSync& operator=(const SpawnSync&); 00409 00410 SpawnSyncData *data_; 00411 00412 public: 00415 00416 SpawnSync(const std::vector<std::string>& argv, SpawnFlagsField flags = 0); 00425 00426 SpawnSync(const std::string& command_line, G::Error *error); 00438 00439 ~SpawnSync(); 00441 00445 00446 int exit_status() const; 00449 00450 std::string standard_output() const; 00455 00456 std::string standard_error() const; 00461 00465 00466 bool execute(G::Error *error = 0); 00470 00471 bool execute(const ChildSetupSlot& slot, G::Error *error = 0); 00476 00478 }; 00479 00480 } // namespace G 00481 00482 } // namespace GFC 00483 00484 #include <gfc/glib/inline/spawn.inl> 00485 00486 #endif // GFC_G_SPAWN_HH 00487

Generated on Tue Aug 24 00:04:56 2004 for GFC-Core by doxygen 1.3.8