[Seems like a plausible idea. If we do a multithreaded server, may need a change in meaning, but as long as we pass something which identifies the connection, that would be doable. Also would need to think about how to handle non-unix operating systems. Of course, should use execve instead of putenv, would need a testcase, needs documentation, maybe one or two other things like that (if it is thought to be a good enough idea to consider making it official, that is). -kingdon] From: Andreas Luik Subject: cvs-1.9: change-request: pass cvs pid to called scripts To: bug-cvs@gnu.org Date: Wed, 12 Aug 1998 21:34:43 +0200 (MET DST) X-Organization: ISA Systems GmbH, Azenbergstr. 35, D-70174 Stuttgart Hi, this is not really a bug report, but a change request to implement a mechanism to pass the ID of the cvs process to the different scripts like loginfo and so on. Background information: we have a set of scripts which perform some actions requiring some locking. We decided to use the (hostname, pid) pair of the cvs process, but it is rather awksome to determine the process id of cvs by computing the PPID, because for example in editinfo, cvs is the parent process, whereas the loginfo script is called via /bin/sh, so cvs is the parent of the parent of loginfo. It would be much easier, if cvs would set a CVSPID environment variable, for example (patch added at end of mail). Can you please consider this enhancement and perhaps send a comment back. Thanks in advance, -- Andreas Luik E-Mail: luik@isa.de (postmaster@isa.de) WWW: http://www.isa.de/~luik PGP: E2 6A 41 70 67 1E 0B 68 94 0D 9E 83 95 16 AF 59 *** cvs-1.9/src/main.c.ORIG Wed Oct 2 08:04:02 1996 --- cvs-1.9/src/main.c Wed Aug 12 18:32:01 1998 *************** *** 344,349 **** --- 344,364 ---- program_name = last_component (argv[0]); #endif + #ifdef HAVE_PUTENV + /* Set the CVSPID environment variable. */ + { + char *env; + pid_t pid; /* assume pid < 10**20 */ + + if ((pid = getpid()) != (pid_t) -1) { + env = xmalloc (strlen (CVSPID_ENV) + 20 + 1 + 1); + (void) sprintf (env, "%s=%lu", CVSPID_ENV, (unsigned long) pid); + (void) putenv (env); + /* do not free env, as putenv has control of it */ + } + } + #endif + /* * Query the environment variables up-front, so that * they can be overridden by command line arguments *** cvs-1.9/src/cvs.h.ORIG Wed Oct 2 08:03:59 1996 --- cvs-1.9/src/cvs.h Wed Aug 12 18:32:02 1998 *************** *** 226,231 **** --- 226,233 ---- #define TAG_BASE "BASE" /* Environment variable used by CVS */ + #define CVSPID_ENV "CVSPID" /* the process ID of cvs */ + #define CVSREAD_ENV "CVSREAD" /* make files read-only */ #define CVSREAD_DFLT FALSE /* writable files by default */