I was playing with the -j option and wanted to understand it more.

I wanted to echo my PID in test targets...but it seems very difficult
to get my PID....if you spawn a shell, you have a new PID
(of course, you can start tracing parent pids but that was cumbersome).

This simple patch makes a variable $(PID) which returns the PID of the
executing make --

: [EMAIL PROTECTED] 10:57:40;rcsdiff -u main.c
===================================================================
RCS file: main.c,v
retrieving revision 1.1
diff -u -r1.1 main.c
--- main.c      2007/10/18 01:44:38     1.1
+++ main.c      2007/10/18 01:50:40
@@ -885,6 +885,16 @@
 #endif
 }

+static  void
+define_pid (void)
+{
+    char pidstring[20];
+
+    sprintf(pidstring, "%d", getpid());
+    define_variable ( "PID", 3, pidstring, o_default, 0);
+
+}
+

 #ifdef _AMIGA
 int
@@ -1446,7 +1456,8 @@
        starting_directory = current_directory;
     }

-  (void) define_variable ("CURDIR", 6, current_directory, o_file, 0);
+  (void) define_variable ("CURDIR", 6, current_directory, o_file, 0);
+  define_pid();

   /* Read any stdin makefiles into temporary files.  */


If there isn't a good way to do this, I'll stick it in the patch manager...

marty



_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to