From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@sunsite.dk
Subject: Re: jobs -Z example?
Date: Sun, 15 Mar 2009 21:08:22 -0700 [thread overview]
Message-ID: <090315210822.ZM15704@torch.brasslantern.com> (raw)
In-Reply-To: <20090316020755.GF24875@dan.emsphone.com>
On Mar 15, 9:07pm, Dan Nelson wrote:
}
} In case it stops working later, all of the *BSDs provide a setproctitle()
I see there's been some discussion about adding setproctitle() to glibc.
Let's try this.
diff -ru -x CVS zsh-forge/current/configure.ac zsh-4.0/configure.ac
--- zsh-forge/current/configure.ac 2009-03-08 14:01:12.000000000 -0700
+++ zsh-4.0/configure.ac 2009-03-15 20:59:52.000000000 -0700
@@ -1885,6 +1885,11 @@
AC_DEFINE(USE_GETCWD)
fi
+dnl CHECK FOR setproctitle() FOR jobs -Z / ARGV0
+AH_TEMPLATE([HAVE_SETPROCTITLE],
+[Define to 1 if the system supports this call to change process name])
+AC_SEARCH_LIBS(setproctitle, util, AC_DEFINE(HAVE_SETPROCTITLE))
+
dnl -------------
dnl CHECK FOR NIS
dnl -------------
diff -ru -x CVS zsh-forge/current/Src/jobs.c zsh-4.0/Src/jobs.c
--- zsh-forge/current/Src/jobs.c 2009-03-14 23:22:20.000000000 -0700
+++ zsh-4.0/Src/jobs.c 2009-03-15 21:03:13.000000000 -0700
@@ -1572,12 +1572,14 @@
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 @@
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 @@
}
done:
hackspace = p - hackzero;
+#endif
}
@@ -1718,10 +1722,14 @@
}
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;
}
next prev parent reply other threads:[~2009-03-16 4:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-15 18:24 Atom Smasher
2009-03-15 19:47 ` Bart Schaefer
2009-03-15 20:49 ` Atom Smasher
2009-03-15 21:05 ` Christian Schneider
2009-03-15 21:07 ` Bart Schaefer
2009-03-15 21:41 ` Atom Smasher
2009-03-15 22:08 ` Bart Schaefer
2009-03-15 22:13 ` Atom Smasher
2009-03-16 2:07 ` Dan Nelson
2009-03-16 4:08 ` Bart Schaefer [this message]
2009-03-16 4:43 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=090315210822.ZM15704@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=zsh-users@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).