Two closely-related new features: property: /sim/pid option: --pid=/pathto/some/file.pid
Having the pid available is useful for many purposes, including sending a signal for debugging. Somebody should please check that this works under MSVC. It looks to me like pretty standard c++ but it's still good to check......... commit cc188f7499c03417b1d4a3cb296702ba7b4d67fa Author: John Denker <j...@av8n.com> Date: Fri Feb 5 10:12:15 2010 -0700 Write pid into property tree and optionally into a file. diff --git a/src/Main/main.cxx b/src/Main/main.cxx index d5ac553..38202e4 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -885,6 +885,7 @@ bool fgMainInit( int argc, char **argv ) { upper_case_property("/sim/presets/runway"); upper_case_property("/sim/tower/airport-id"); upper_case_property("/autopilot/route-manager/input"); + fgSetInt ("/sim/pid", getpid() ); // Scan the config file(s) and command line options to see if // fg_root was specified (ignore all other options for now) diff --git a/src/Main/options.cxx b/src/Main/options.cxx index 3b4354f..9eb41b5 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -39,6 +39,7 @@ #include <string.h> // strcmp() #include <algorithm> +#include <fstream> /* ofstream */ #include <iostream> #include <string> @@ -1234,7 +1235,20 @@ fgOptFgviewer(const char* arg) return FG_OPTIONS_OK; } - +static int +fgOptPid(const char* arg) +{ + pid_t pid = getpid(); + ofstream out; + out.open(arg, ofstream::out); + out << pid << endl; + out.close(); + if (!out.good()) { + SG_LOG(SG_GENERAL, SG_ALERT, + "Unable to write pid (" << pid + << ") to file '" << arg << "'"); + } +} static map<string,size_t> fgOptionMap; @@ -1449,6 +1463,7 @@ struct OptionDesc { {"version", false, OPTION_FUNC, "", false, "", fgOptVersion }, {"enable-fpe", false, OPTION_FUNC, "", false, "", fgOptFpe}, {"fgviewer", false, OPTION_FUNC, "", false, "", fgOptFgviewer}, + {"pid", true, OPTION_FUNC, "", false, "", fgOptPid }, {0} }; ------------------------------------------------------------------------------ The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com _______________________________________________ Flightgear-devel mailing list Flightgear-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/flightgear-devel