From ddeafa3b0240acc12002cdd29222ebd47967558b Mon Sep 17 00:00:00 2001 From: Eric Allman Date: Fri, 9 Sep 1994 23:47:22 -0800 Subject: [PATCH] change setproctitle definitions to use SPT_TYPE variable a la SFS_TYPE and LA_TYPE; this allows for a cleaner integration of new types SCCS-vsn: usr.sbin/sendmail/src/READ_ME 8.71 SCCS-vsn: usr.sbin/sendmail/src/main.c 8.66 SCCS-vsn: usr.sbin/sendmail/src/conf.h 8.120 SCCS-vsn: usr.sbin/sendmail/src/conf.c 8.103 --- usr/src/usr.sbin/sendmail/src/READ_ME | 20 ++++++-- usr/src/usr.sbin/sendmail/src/conf.c | 67 ++++++++++++++------------- usr/src/usr.sbin/sendmail/src/conf.h | 16 ++++--- usr/src/usr.sbin/sendmail/src/main.c | 6 +-- 4 files changed, 60 insertions(+), 49 deletions(-) diff --git a/usr/src/usr.sbin/sendmail/src/READ_ME b/usr/src/usr.sbin/sendmail/src/READ_ME index b03356753b..7d7cedb610 100644 --- a/usr/src/usr.sbin/sendmail/src/READ_ME +++ b/usr/src/usr.sbin/sendmail/src/READ_ME @@ -4,7 +4,7 @@ # # %sccs.include.redist.sh% # -# @(#)READ_ME 8.70 (Berkeley) %G% +# @(#)READ_ME 8.71 (Berkeley) %G% # This directory contains the source files for sendmail. @@ -290,6 +290,19 @@ SFS_TYPE Encodes how your kernel can locate the amount of free , , or respectively, or SFS_STATVFS (6) if you have the two-argument statvfs(2) call. The default if nothing is defined is SFS_NONE. +SPT_TYPE Encodes how your system can display what a process is doing + on a ps(1) command (SPT stands for Set Process Title). Can + be set to: + SPT_NONE (0) -- Don't try to set the process title at all. + SPT_REUSEARGV (1) -- Pad out your argv with the information; + this is the default if none specified. + SPT_BUILTIN (2) -- The system library has setproctitle. + SPT_PSTAT (3) -- Use the PSTAT_SETCMD option to pstat(2) + to set the process title; this is used by HP-UX. + SPT_PSSTRINGS (4) -- Use the magic PS_STRINGS pointer (4.4BSD). +SPT_PADCHAR Character used to pad the process title; if undefined, + the space character (0x20) is used. This is ignored if + SPT_TYPE != SPT_REUSEARGV ERRLIST_PREDEFINED If set, assumes that some header file defines sys_errlist. This may be needed if you get type conflicts on this @@ -368,9 +381,6 @@ MATCHGECOS Permit fuzzy matching of user names against the full name (GECOS) field in the /etc/passwd file. This should probably be on, since you can disable it from the config file if you want to. Defined by default in conf.h. -SETPROCTITLE Try to set the string printed by "ps" to something - informative about what sendmail is doing. Defined by - default in conf.h. +---------------------+ @@ -880,4 +890,4 @@ version.c The version number and information about this Eric Allman -(Version 8.70, last update %G% 18:07:44) +(Version 8.71, last update %G% 16:46:51) diff --git a/usr/src/usr.sbin/sendmail/src/conf.c b/usr/src/usr.sbin/sendmail/src/conf.c index 92e109df9f..6acb898917 100644 --- a/usr/src/usr.sbin/sendmail/src/conf.c +++ b/usr/src/usr.sbin/sendmail/src/conf.c @@ -7,7 +7,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)conf.c 8.102 (Berkeley) %G%"; +static char sccsid[] = "@(#)conf.c 8.103 (Berkeley) %G%"; #endif /* not lint */ # include "sendmail.h" @@ -1025,58 +1025,61 @@ refuseconnections() ** display the title. */ -#ifdef SETPROCTITLE +#define SPT_NONE 0 /* don't use it at all */ +#define SPT_REUSEARGV 1 /* cover argv with title information */ +#define SPT_BUILTIN 2 /* use libc builtin */ +#define SPT_PSTAT 3 /* use pstat(PSTAT_SETCMD, ...) */ +#define SPT_PSSTRINGS 4 /* use PS_STRINGS->... */ +#define SPT_WRITEUDOT 5 /* write u. area in kmem */ -# ifdef HASSETPROCTITLE - *** ERROR *** Cannot have both SETPROCTITLE and HASSETPROCTITLE defined -# endif +#ifndef SPT_TYPE +# define SPT_TYPE SPT_REUSEARGV +#endif + +#if SPT_TYPE != SPT_NONE && SPT_TYPE != SPT_BUILTIN -# ifdef __hpux +# if SPT_TYPE == SPT_PSTAT # include # endif -# ifdef BSD4_4 +# if SPT_TYPE == SPT_PSSTRINGS # include # include -# ifdef __bsdi__ -# undef PS_STRINGS /* BSDI 1.0 doesn't do PS_STRINGS as we expect */ -# define PROCTITLEPAD '\0' +# ifndef PS_STRINGS /* hmmmm.... apparently not available after all */ +# undef SPT_TYPE +# define SPT_TYPE SPT_REUSEARGV # endif -# ifdef PS_STRINGS -# define SETPROC_STATIC static -# endif -# endif -# ifdef _AIX3 -# define PROCTITLEPAD '\0' # endif -# ifndef SETPROC_STATIC +# if SPT_TYPE == SPT_PSSTRINGS +# define SETPROC_STATIC static +# else # define SETPROC_STATIC # endif -#endif +# ifndef SPT_PADCHAR +# define SPT_PADCHAR ' ' +# endif -#ifndef PROCTITLEPAD -# define PROCTITLEPAD ' ' -#endif +#endif /* SPT_TYPE != SPT_NONE && SPT_TYPE != SPT_BUILTIN */ -#ifndef HASSETPROCTITLE +#if SPT_TYPE != SPT_BUILTIN char ProcTitleBuf[MAXLINE]; /*VARARGS1*/ -#ifdef __STDC__ +# ifdef __STDC__ setproctitle(char *fmt, ...) -#else +# else setproctitle(fmt, va_alist) char *fmt; va_dcl -#endif +# endif { -# ifdef SETPROCTITLE +# if SPT_TYPE != SPT_NONE register char *p; register int i; VA_LOCAL_DECL -# ifdef __hpux +# if SPT_TYPE == SPT_PSTAT union pstun pst; # endif extern char **Argv; @@ -1110,14 +1113,14 @@ setproctitle(fmt, va_alist) (void) strcpy(Argv[0], ProcTitleBuf); p = &Argv[0][i]; while (p < LastArgv) - *p++ = PROCTITLEPAD; + *p++ = SPT_PADCHAR; Argv[1] = NULL; -# endif -# endif -# endif /* SETPROCTITLE */ +# endif /* SPT_TYPE == SPT_PSSTRINGS */ +# endif /* SPT_TYPE == SPT_PSTAT */ +# endif /* SPT_TYPE != SPT_NONE */ } -#endif +#endif /* SPT_TYPE != SPT_BUILTIN */ /* ** REAPCHILD -- pick up the body of my child, lest it become a zombie ** diff --git a/usr/src/usr.sbin/sendmail/src/conf.h b/usr/src/usr.sbin/sendmail/src/conf.h index 4429d546f1..496789e6c8 100644 --- a/usr/src/usr.sbin/sendmail/src/conf.h +++ b/usr/src/usr.sbin/sendmail/src/conf.h @@ -5,7 +5,7 @@ * * %sccs.include.redist.c% * - * @(#)conf.h 8.119 (Berkeley) %G% + * @(#)conf.h 8.120 (Berkeley) %G% */ /* @@ -55,7 +55,6 @@ # define UGLYUUCP 1 /* output ugly UUCP From lines */ # define NETUNIX 1 /* include unix domain support */ # define NETINET 1 /* include internet support */ -# define SETPROCTITLE 1 /* munge argv to display current status */ # define MATCHGECOS 1 /* match user names from gecos field */ # define XDEBUG 1 /* enable extended debugging */ # ifdef NEWDB @@ -147,6 +146,7 @@ extern int syslog(int, char *, ...); # define HASGETUSERSHELL 0 /* does not have getusershell(3) call */ # define FORK fork /* no vfork primitive available */ # define SFS_TYPE SFS_STATFS /* use statfs() impl */ +# define SPT_PADCHAR '\0' /* pad process title with nulls */ #endif @@ -264,7 +264,7 @@ extern char *getenv(); # ifndef IDENTPROTO # define IDENTPROTO 0 /* TCP/IP implementation is broken */ # endif -# undef SETPROCTITLE +# define SPT_TYPE SPT_NONE /* don't use setproctitle */ # define SFS_TYPE SFS_4ARGS /* four argument statfs() call */ /* these include files must be included early on DG/UX */ @@ -373,6 +373,7 @@ typedef int pid_t; # define LA_TYPE LA_SUBR # endif # define SFS_TYPE SFS_MOUNT /* use statfs() impl */ +# define SPT_TYPE SPT_PSSTRINGS /* use PS_STRINGS pointer */ #endif @@ -392,13 +393,14 @@ typedef int pid_t; # endif # if defined(_BSDI_VERSION) && _BSDI_VERSION >= 199312 /* version 1.1 or later */ -# define HASSETPROCTITLE 1 /* setproctitle is in libc */ -# undef SETPROCTITLE /* so don't redefine it in conf.c */ +# undef SPT_TYPE +# define SPT_TYPE SPT_BUILTIN /* setproctitle is in libc */ # else /* version 1.0 or earlier */ # ifndef OLD_NEWDB # define OLD_NEWDB 1 /* old version of newdb library */ # endif +# define SPT_PADCHAR '\0' /* pad process title with nulls */ # endif #endif @@ -760,7 +762,7 @@ typedef int pid_t; # define GIDSET_T gid_t # define LA_TYPE LA_INT # define SFS_TYPE SFS_STATFS /* use statfs() impl */ -# undef SETPROCTITLE +# define SPT_TYPE SPT_NONE /* don't use setproctitle */ # ifndef IDENTPROTO # define IDENTPROTO 0 /* TCP/IP implementation is broken */ # endif @@ -800,7 +802,7 @@ typedef int pid_t; #ifdef apollo # define HASSETREUID 1 /* has setreuid(2) call */ # define HASINITGROUPS 1 /* has initgroups(2) call */ -# undef SETPROCTITLE +# define SPT_TYPE SPT_NONE /* don't use setproctitle */ # define LA_TYPE LA_SUBR /* use getloadavg.c */ # define SFS_TYPE SFS_4ARGS /* four argument statfs() call */ # ifndef _PATH_SENDMAILCF diff --git a/usr/src/usr.sbin/sendmail/src/main.c b/usr/src/usr.sbin/sendmail/src/main.c index fdfc135243..bca84bf6ae 100644 --- a/usr/src/usr.sbin/sendmail/src/main.c +++ b/usr/src/usr.sbin/sendmail/src/main.c @@ -13,7 +13,7 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)main.c 8.65 (Berkeley) %G%"; +static char sccsid[] = "@(#)main.c 8.66 (Berkeley) %G%"; #endif /* not lint */ #define _DEFINE @@ -79,10 +79,8 @@ bool Warn_Q_option = FALSE; /* warn about Q option use */ ** This allows "ps" listings to give more useful information. */ -# ifdef SETPROCTITLE char **Argv = NULL; /* pointer to argument vector */ char *LastArgv = NULL; /* end of argv */ -# endif /* SETPROCTITLE */ static void obsolete(); @@ -278,7 +276,6 @@ main(argc, argv, envp) UserEnviron[j] = NULL; environ = UserEnviron; -# ifdef SETPROCTITLE /* ** Save start and extent of argv for setproctitle. */ @@ -288,7 +285,6 @@ main(argc, argv, envp) LastArgv = envp[i - 1] + strlen(envp[i - 1]); else LastArgv = argv[argc - 1] + strlen(argv[argc - 1]); -# endif /* SETPROCTITLE */ if (setsignal(SIGINT, SIG_IGN) != SIG_IGN) (void) setsignal(SIGINT, intsig); -- 2.20.1