different login shell

This commit is contained in:
rsc 2006-01-18 23:11:00 +00:00
parent 8a6837e8c0
commit 5bd21066c5
3 changed files with 15 additions and 2 deletions

View file

@ -59,6 +59,9 @@ threadmain(int argc, char *argv[])
ARGBEGIN{
default:
usage();
case 'l':
loginshell = TRUE;
break;
case 'f':
fontname = EARGF(usage());
break;

View file

@ -3,6 +3,8 @@
#include <libc.h>
#include "term.h"
int loginshell;
static void
sys(char *buf, int devnull)
{
@ -31,7 +33,7 @@ int
rcstart(int argc, char **argv, int *pfd, int *tfd)
{
int fd[2], i, pid;
char *xargv[3];
char *cmd, *xargv[3];
char slave[256];
int sfd;
@ -44,6 +46,13 @@ rcstart(int argc, char **argv, int *pfd, int *tfd)
argv[1] = "-i";
argv[2] = 0;
}
cmd = argv[0];
if(loginshell){
argv[0] = malloc(strlen(cmd)+2);
strcpy(argv[0]+1, cmd);
argv[0][0] = '-';
}
/*
* fd0 is slave (tty), fd1 is master (pty)
*/
@ -85,7 +94,7 @@ rcstart(int argc, char **argv, int *pfd, int *tfd)
signal(SIGINT, SIG_DFL);
signal(SIGHUP, SIG_DFL);
signal(SIGTERM, SIG_DFL);
execvp(argv[0], argv);
execvp(cmd, argv);
fprint(2, "exec %s failed: %r\n", argv[0]);
_exit(2);
break;

View file

@ -7,3 +7,4 @@ extern int isecho(int);
extern int setecho(int, int);
extern int noecho;
extern int getintr(int);
extern int loginshell;