From 13bd077bb466b274bab0710fddf7633c9b63e7b5 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Fri, 17 Sep 2004 17:35:53 +0000
Subject: [PATCH] add -pid command line option to print the process id on
 stdout

---
 Common/CommandLine.cpp        | 11 +++++++++--
 doc/gmsh.1                    |  5 ++++-
 doc/texinfo/command_line.texi |  2 ++
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/Common/CommandLine.cpp b/Common/CommandLine.cpp
index 61c04d4721..c56bc8b8ab 100644
--- a/Common/CommandLine.cpp
+++ b/Common/CommandLine.cpp
@@ -1,4 +1,4 @@
-// $Id: CommandLine.cpp,v 1.46 2004-07-01 22:23:10 geuzaine Exp $
+// $Id: CommandLine.cpp,v 1.47 2004-09-17 17:35:53 geuzaine Exp $
 //
 // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
@@ -19,6 +19,7 @@
 // 
 // Please report all bugs and problems to <gmsh@geuz.org>.
 
+#include <sys/types.h>
 #include <unistd.h>
 #include "Gmsh.h"
 #include "GmshUI.h"
@@ -101,6 +102,7 @@ void Print_Usage(char *name){
 #if defined(HAVE_FLTK)
   Msg(DIRECT, "  -a, -g, -m, -s, -p    start in automatic, geometry, mesh, solver or post-processing mode");
 #endif
+  Msg(DIRECT, "  -pid                  print pid on stdout");
   Msg(DIRECT, "  -v int                set verbosity level");
   Msg(DIRECT, "  -string \"string\"      parse string before project file");
   Msg(DIRECT, "  -option file          parse option file before GUI creation");
@@ -165,7 +167,12 @@ void Get_Options(int argc, char *argv[], int *nbfiles)
 
     if(argv[i][0] == '-') {
 
-      if(!strcmp(argv[i] + 1, "string")) {
+      if(!strcmp(argv[i] + 1, "pid")) {
+	fprintf(stdout, "%d\n", getpid());
+	fflush(stdout);
+        i++;
+      }
+      else if(!strcmp(argv[i] + 1, "string")) {
         i++;
         if(argv[i] != NULL)
           TheOptString = argv[i++];
diff --git a/doc/gmsh.1 b/doc/gmsh.1
index 48ed728316..9c3e20460d 100644
--- a/doc/gmsh.1
+++ b/doc/gmsh.1
@@ -1,4 +1,4 @@
-.\" $Id: gmsh.1,v 1.57 2004-07-01 22:23:11 geuzaine Exp $
+.\" $Id: gmsh.1,v 1.58 2004-09-17 17:35:53 geuzaine Exp $
 .TH Gmsh 1 "1 July 2004" "Gmsh 1.54" "Gmsh Manual Pages"
 .UC 4
 .\" ********************************************************************
@@ -125,6 +125,9 @@ specify display.
 .B \-a, \-g, \-m, \-s, \-p
 start in automatic, geometry, mesh, solver or post-processing mode.
 .TP 4
+.B \-pid
+print pid on stdout.
+.TP 4
 .B \-v int
 set verbosity level.
 .TP 4
diff --git a/doc/texinfo/command_line.texi b/doc/texinfo/command_line.texi
index dff03802bd..d3a6df83f8 100644
--- a/doc/texinfo/command_line.texi
+++ b/doc/texinfo/command_line.texi
@@ -85,6 +85,8 @@ specify display
 @ftable @code
 @item -a, -g, -m, -s, -p
 start in automatic, geometry, mesh, solver or post-processing mode
+@item -pid
+print pid on stdout
 @item -v int
 set verbosity level
 @item -string "string"
-- 
GitLab