[distcc] [PATCH] Cygwin support (pid length fix)

Aaron Lehmann aaronl at vitelus.com
Thu Aug 15 23:21:02 GMT 2002


Now you can steal the cycles of people running less enlightened
operating systems. distccd would work out of the box on cygwin, except
for the fact that PIDs on cygwin range up to the high millions. This
patch changes the maximum PID string length to 10 digits, enough to
fit the highest number that can be represented in a 32-bit pid_t.

Do any platforms have 64-bit pid_t's?

--- src/tempfile.c~	2002-08-16 01:14:22.000000000 -0700
+++ src/tempfile.c	2002-08-16 01:14:41.000000000 -0700
@@ -155,13 +155,13 @@
     assert(i < N_CLEANUPS);
 
     /* NOTE: Make sure this lines up with the printf statement.  C sucks. */
-    need_len = strlen(tempdir) + 1 + strlen(prefix) + 1 + 7 
+    need_len = strlen(tempdir) + 1 + strlen(prefix) + 1 + 10 
         + strlen(suffix) + 1;
     
     if ((s = malloc(need_len)) == NULL) {
         rs_fatal("failed to allocate %d", need_len);
     }
-    if ((snprintf(s, need_len, "%s/%s_%07d%s", tempdir, prefix, getpid(), suffix)) != need_len - 1) {
+    if ((snprintf(s, need_len, "%s/%s_%010d%s", tempdir, prefix, getpid(), suffix)) != need_len - 1) {
         rs_fatal("string length was wrong??");
         abort();
     }



More information about the distcc mailing list