about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--Src/jobs.c8
-rw-r--r--configure.ac6
3 files changed, 20 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 25d857495..db1acb35e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-03-15  Barton E. Schaefer  <schaefer@zsh.org>
+
+	* users/13937, users/13939: configure.ac, Src/jobs.c: check for
+	and if available use setproctitle() for "jobs -Z".
+
 2009-03-15  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
 	* 26736: Doc/Zsh/expn.yo: document 26731.
@@ -11416,5 +11421,5 @@
 
 *****************************************************
 * This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.4618 $
+* $Revision: 1.4619 $
 *****************************************************
diff --git a/Src/jobs.c b/Src/jobs.c
index 666d90966..df1787b79 100644
--- a/Src/jobs.c
+++ b/Src/jobs.c
@@ -1572,12 +1572,14 @@ getjob(const char *s, const char *prog)
     return returnval;
 }
 
+#ifndef HAVE_SETPROCTITLE
 /* For jobs -Z (which modifies the shell's name as seen in ps listings).  *
  * hackzero is the start of the safely writable space, and hackspace is   *
  * its length, excluding a final NUL terminator that will always be left. */
 
 static char *hackzero;
 static int hackspace;
+#endif
 
 
 /* Initialise job handling. */
@@ -1600,6 +1602,7 @@ init_jobs(char **argv, char **envp)
     jobtabsize = MAXJOBS_ALLOC;
     memset(jobtab, 0, init_bytes);
 
+#ifndef HAVE_SETPROCTITLE
     /*
      * Initialise the jobs -Z system.  The technique is borrowed from
      * perl: check through the argument and environment space, to see
@@ -1622,6 +1625,7 @@ init_jobs(char **argv, char **envp)
     }
     done:
     hackspace = p - hackzero;
+#endif
 }
 
 
@@ -1718,10 +1722,14 @@ bin_fg(char *name, char **argv, Options ops, int func)
 	}
 	queue_signals();
 	unmetafy(*argv, &len);
+#ifdef HAVE_SETPROCTITLE
+	setproctitle("%s", *argv);
+#else
 	if(len > hackspace)
 	    len = hackspace;
 	memcpy(hackzero, *argv, len);
 	memset(hackzero + len, 0, hackspace - len);
+#endif
 	unqueue_signals();
 	return 0;
     }
diff --git a/configure.ac b/configure.ac
index 296172224..fb145ef3e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1885,6 +1885,12 @@ if test x$zsh_cv_use_getcwd = xyes; then
   AC_DEFINE(USE_GETCWD)
 fi
 
+dnl CHECK FOR setproctitle() FOR jobs -Z / ARGV0
+AH_TEMPLATE([HAVE_SETPROCTITLE],
+[Define to 1 if the system supports `setproctitle' to change process name])
+AC_CHECK_FUNC(setproctitle,AC_DEFINE(HAVE_SETPROCTITLE),
+AC_SEARCH_LIBS(setproctitle,util,AC_DEFINE(HAVE_SETPROCTITLE)))
+
 dnl -------------
 dnl CHECK FOR NIS
 dnl -------------