[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RFC: discovering make's PID
From: |
Marty Leisner |
Subject: |
RFC: discovering make's PID |
Date: |
Wed, 17 Oct 2007 23:03:20 -0400 |
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 --
: address@hidden 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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- RFC: discovering make's PID,
Marty Leisner <=