* [PATCH 1/3] script: Split doexec() out of doshell()
@ 2015-02-10 21:30 Stanislav Brabec
0 siblings, 0 replies; only message in thread
From: Stanislav Brabec @ 2015-02-10 21:30 UTC (permalink / raw)
To: util-linux
Create doshell() that will be needed by --interactive.
---
term-utils/script.c | 46 ++++++++++++++++++++++++++--------------------
1 file changed, 26 insertions(+), 20 deletions(-)
diff --git a/term-utils/script.c b/term-utils/script.c
index 02ba596..14a44e1 100644
--- a/term-utils/script.c
+++ b/term-utils/script.c
@@ -90,6 +90,7 @@ void getmaster(void);
void getslave(void);
void doinput(void);
void dooutput(void);
+void doexec(void);
void doshell(void);
char *shell;
@@ -508,9 +509,32 @@ dooutput(void) {
}
void
-doshell(void) {
+doexec(void) {
char *shname;
+ shname = strrchr(shell, '/');
+ if (shname)
+ shname++;
+ else
+ shname = shell;
+
+ if (access(shell, X_OK) == 0) {
+ if (cflg)
+ execl(shell, shname, "-c", cflg, NULL);
+ else
+ execl(shell, shname, "-i", NULL);
+ } else {
+ if (cflg)
+ execlp(shname, "-c", cflg, NULL);
+ else
+ execlp(shname, "-i", NULL);
+ }
+ warn(_("failed to execute %s"), shell);
+ fail();
+}
+
+void
+doshell(void) {
getslave();
/* close things irrelevant for this process */
@@ -528,12 +552,6 @@ doshell(void) {
master = -1;
- shname = strrchr(shell, '/');
- if (shname)
- shname++;
- else
- shname = shell;
-
/*
* When invoked from within /etc/csh.login, script spawns a csh shell
* that spawns programs that cannot be killed with a SIGTERM. This is
@@ -544,19 +562,7 @@ doshell(void) {
*/
signal(SIGTERM, SIG_DFL);
- if (access(shell, X_OK) == 0) {
- if (cflg)
- execl(shell, shname, "-c", cflg, NULL);
- else
- execl(shell, shname, "-i", NULL);
- } else {
- if (cflg)
- execlp(shname, "-c", cflg, NULL);
- else
- execlp(shname, "-i", NULL);
- }
- warn(_("failed to execute %s"), shell);
- fail();
+ doexec();
}
void
--
2.2.2
--
Best Regards / S pozdravem,
Stanislav Brabec
software developer
---------------------------------------------------------------------
SUSE LINUX, s. r. o. e-mail: sbrabec@suse.cz
Lihovarská 1060/12 tel: +49 911 7405384547
190 00 Praha 9 fax: +420 284 084 001
Czech Republic http://www.suse.cz/
PGP: 830B 40D5 9E05 35D8 5E27 6FA3 717C 209F A04F CD76
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2015-02-10 21:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-10 21:30 [PATCH 1/3] script: Split doexec() out of doshell() Stanislav Brabec
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.