kiwi-el8/tools/startshell.c
Marcus Schäfer 8c60ef66c5
Move all build and install tasks to setup.py
In an effort to distribute kiwi on pypi it should not be
required to call make targets for a complete installation.
Therefore the compilation of the C tools as well as the
installation of the man pages and the bash completion
has been added to setup.py. The spec file to build an rpm
package has been changed to use setup.py exclusively
2016-05-30 19:07:49 +02:00

50 lines
1.0 KiB
C

#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <stdlib.h>
#include <unistd.h>
static int
inst_start_shell (char *tty_tv) {
char *args_apci [] = { "bash", 0 };
char *env_pci [] = {
"TERM=linux",
"PS1=`pwd -P` # ",
"HOME=/",
"HISTFILE=",
"PATH=/lbin:/bin:/sbin:/usr/bin:/usr/sbin", 0
};
int fd_ii;
int sh_pid = fork ();
if (sh_pid != 0)
return sh_pid; /* parent */
fclose (stdin);
fclose (stdout);
fclose (stderr);
setsid ();
fd_ii = open (tty_tv, O_RDWR);
ioctl (fd_ii, TIOCSCTTY, (void *)1);
(void)dup (fd_ii);
(void)dup (fd_ii);
execve ("/bin/bash", args_apci, env_pci);
fprintf (stderr, "Couldn't start shell (errno = %d)\n", errno);
exit (-1);
/*NOTREACHED*/
return 0;
}
int main(int argc, char **argv) {
int i;
int last_pid = 0;
for (i=1; i<argc; i++) {
last_pid = inst_start_shell (argv[i]);
}
printf ("%d\n", last_pid);
return 0;
}