--- old/usr/src/cmd/pbind/pbind.c	Tue Dec 29 19:12:18 2015
+++ new/usr/src/cmd/pbind/pbind.c	Tue Dec 29 19:12:18 2015
@@ -20,12 +20,11 @@
  * CDDL HEADER END
  */
 /*
+ * Copyright 2015 Ryan Zezeski
  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 /*
  * pbind - bind a process to a processor (non-exclusively)
  */
@@ -54,6 +53,7 @@
 
 static char	*progname;
 static char	bflag;
+static char	eflag;
 static char	qflag;
 static char	Qflag;
 static char	uflag;
@@ -165,17 +165,17 @@
 	if (old == PBIND_NONE) {
 		if (new == PBIND_NONE)
 			(void) printf(gettext("%s id %s: was not bound, "
-				"now not bound\n"), proclwp, pidstr);
+			    "now not bound\n"), proclwp, pidstr);
 		else
 			(void) printf(gettext("%s id %s: was not bound, "
-				"now %d\n"), proclwp, pidstr, new);
+			    "now %d\n"), proclwp, pidstr, new);
 	} else {
 		if (new == PBIND_NONE)
 			(void) printf(gettext("%s id %s: was %d, "
-				"now not bound\n"), proclwp, pidstr, old);
+			    "now not bound\n"), proclwp, pidstr, old);
 		else
 			(void) printf(gettext("%s id %s: was %d, "
-				"now %d\n"), proclwp, pidstr, old, new);
+			    "now %d\n"), proclwp, pidstr, old, new);
 	}
 }
 
@@ -345,11 +345,45 @@
 	return (0);
 }
 
+/*
+ * Execute the cmd with args while bound to cpu. Does not return:
+ * either executes cmd successfully or dies trying.
+ */
+static void
+exec_cmd(processorid_t cpu, char *cmd, char **args)
+{
+	if (processor_bind(P_PID, P_MYID, cpu, NULL) == -1) {
+		bind_err(cpu, getpid(), -1, errno);
+		exit(ERR_FAIL);
+	}
+
+	if (execvp(cmd, args) == -1)
+		die(gettext("failed to exec %s\n"), cmd);
+}
+
+/*
+ * Attempt to parse str as a CPU identifier. Return the identifier or
+ * die.
+ */
+static processorid_t
+parse_cpu(char *str)
+{
+	processorid_t cpu;
+	char *endstr;
+
+	cpu = strtol(str, &endstr, 10);
+	if (endstr != NULL && *endstr != '\0' || cpu < 0)
+		die(gettext("invalid processor ID %s\n"), optarg);
+
+	return (cpu);
+}
+
 static int
 usage(void)
 {
 	(void) fprintf(stderr,
 	    gettext("usage: \n\t%1$s -b processor_id pid[/lwpids] ...\n"
+	    "\t%1$s -e processor_id cmd [args...]\n"
 	    "\t%1$s -U [processor_id] ...\n"
 	    "\t%1$s -Q [processor_id] ...\n"
 	    "\t%1$s -u pid[/lwpids] ...\n"
@@ -372,17 +406,19 @@
 	(void) setlocale(LC_ALL, "");	/* setup localization */
 	(void) textdomain(TEXT_DOMAIN);
 
-	while ((c = getopt(argc, argv, "b:qQuU")) != EOF) {
+	while ((c = getopt(argc, argv, "b:e:qQuU")) != EOF) {
 		switch (c) {
 
 		case 'b':
 			bflag = 1;
-			cpu = strtol(optarg, &endstr, 10);
-			if (endstr != NULL && *endstr != '\0' || cpu < 0)
-				die(gettext("invalid processor ID %s\n"),
-				    optarg);
+			cpu = parse_cpu(optarg);
 			break;
 
+		case 'e':
+			eflag = 1;
+			cpu = parse_cpu(optarg);
+			break;
+
 		case 'q':
 			qflag = 1;
 			cpu = PBIND_QUERY;
@@ -409,15 +445,15 @@
 
 
 	/*
-	 * Make sure that at most one of the options b, q, Q, u, or U
-	 * was specified.
+	 * Make sure that at most one of the options b, e, q, Q, u, or
+	 * U was specified.
 	 */
-	c = bflag + qflag + Qflag + uflag + Uflag;
+	c = bflag + eflag + qflag + Qflag + uflag + Uflag;
 	if (c < 1) {				/* nothing specified */
 		qflag = 1;			/* default to query */
 		cpu = PBIND_QUERY;
 	} else if (c > 1) {
-		warn(gettext("options -b, -q, -Q, -u and -U "
+		warn(gettext("options -b, -e, -q, -Q, -u and -U "
 		    "are mutually exclusive\n"));
 		return (usage());
 	}
@@ -434,6 +470,10 @@
 			warn(gettext("must specify at least one pid\n"));
 			return (usage());
 		}
+		if (eflag) {
+			warn(gettext("must specify command\n"));
+			return (usage());
+		}
 		if (Uflag) {
 			if (processor_bind(P_ALL, 0, PBIND_NONE, &old_cpu) != 0)
 				die(gettext("failed to unbind some LWPs"));
@@ -447,6 +487,9 @@
 		}
 	}
 
+	if (eflag)
+		exec_cmd(cpu, argv[0], argv);
+
 	if (Qflag || Uflag) {
 		/*
 		 * Go through listed processor IDs.
--- old/usr/src/man/man1m/pbind.1m	Tue Dec 29 19:12:18 2015
+++ new/usr/src/man/man1m/pbind.1m	Tue Dec 29 19:12:18 2015
@@ -1,4 +1,5 @@
 '\" te
+.\"  Copyright 2015 Ryan Zezeski
 .\"  Copyright (c) 2008, Sun Microsystems, Inc.
 .\"  All Rights Reserved
 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
@@ -15,6 +16,11 @@
 
 .LP
 .nf
+\fBpbind\fR \fB-e\fR \fIprocessor_id\fR \fIcmd\fR [\fIargs\fR...]
+.fi
+
+.LP
+.nf
 \fBpbind\fR [\fB-q\fR] [\fIpid\fR [\fI/lwpid\fR]]...
 .fi
 
@@ -34,7 +40,6 @@
 .fi
 
 .SH DESCRIPTION
-.sp
 .LP
 \fBpbind\fR controls and queries bindings of processes and LWPs (lightweight
 processes) to processors. \fBpbind\fR can also remove processor bindings that
@@ -52,11 +57,15 @@
 example, binds all commands executed by the shell.
 .sp
 .LP
+The \fIprocessor_id\fR must be present and on-line. Use the
+\fBpsrinfo(1M)\fR command to determine which processors are
+available.
+.sp
+.LP
 Superusers may bind or unbind any process or LWP, while other users can bind or
 unbind any process or LWP for which they have permission to signal, that is,
 any process that has the same effective user ID as the user.
 .SH OPTIONS
-.sp
 .LP
 The following options are supported:
 .sp
@@ -66,16 +75,23 @@
 .ad
 .sp .6
 .RS 4n
-Binds all or a subset of the LWPs of the specified processes to the processor
-\fIprocessor_id\fR. Specify \fIprocessor_id\fR as the processor \fBID\fR of the
-processor to be controlled or queried. \fIprocessor_id\fR must be present and
-on-line. Use the \fBpsrinfo\fR command to determine whether or not
-\fIprocessor_id\fR is present and on-line. See \fBpsrinfo\fR(1M).
+Binds all or a subset of the LWPs of the specified processes to
+\fIprocessor_id\fR.
 .RE
 
 .sp
 .ne 2
 .na
+\fB-e\fR \fIprocessor_id\fR
+.ad
+.sp .6
+.RS 4n
+Execute a command while bound to \fIprocessor_id\fR.
+.RE
+
+.sp
+.ne 2
+.na
 \fB\fB-q\fR\fR
 .ad
 .sp .6
@@ -123,7 +139,6 @@
 .RE
 
 .SH OPERANDS
-.sp
 .LP
 The following operands are supported:
 .sp
@@ -166,6 +181,16 @@
 The processor \fBID\fR of the processor to be controlled or queried.
 .RE
 
+.sp
+.ne 2
+.na
+\fB\fIcmd\fR \fI[args...]\fR
+.ad
+.sp .6
+.RS 4n
+The command to execute along with optional arguments.
+.RE
+
 .SH EXAMPLES
 .LP
 \fBExample 1 \fRBinding Processes
@@ -249,9 +274,22 @@
 .in -2
 .sp
 
-.SH EXIT STATUS
+.LP
+\fBExample 6 \fRExecuting a bound command:
 .sp
 .LP
+The following example executes ls while bound to processor 6:
+
+.sp
+.in +2
+.nf
+example% \fBpbind -e 6 ls -la
+.fi
+.in -2
+.sp
+
+.SH EXIT STATUS
+.LP
 The following exit values are returned:
 .sp
 .ne 2
@@ -274,12 +312,10 @@
 .RE
 
 .SH SEE ALSO
-.sp
 .LP
 \fBpsradm\fR(1M), \fBpsrinfo\fR(1M), \fBpsrset\fR(1M), \fBprocessor_bind\fR(2),
 \fBprocessor_info\fR(2), \fBsysconf\fR(3C), \fBattributes\fR(5)
 .SH DIAGNOSTICS
-.sp
 .ne 2
 .na
 \fB\fBpbind: cannot query pid 31: No such process\fR\fR
@@ -309,3 +345,12 @@
 The specified processor is not on-line.
 .RE
 
+.sp
+.ne 2
+.na
+\fBpbind: failed to exec\fR \fIcmd\fR
+.ad
+.sp .6
+.RS 4n
+Could not resolve the \fIcmd\fR from \fBPATH\fR.
+.RE
