Dr. Werner Fink 2012-02-13 14:18:04 +00:00 committed by Git OBS Bridge
parent c082b4710e
commit d35793240d

View File

@ -1,5 +1,43 @@
--- src/cmd/builtin/pty.c
+++ src/cmd/builtin/pty.c 2012-02-13 13:35:02.577933517 +0000
@@ -215,6 +215,12 @@ mkpty(int* master, int* slave)
#if !_lib_openpty
char* sname;
#endif
+#ifdef __linux__
+ sigset_t blckttou, oldset;
+ (void)sigemptyset(&blckttou);
+ (void)sigaddset(&blckttou, SIGTTOU);
+ sigprocmask(SIG_BLOCK, &blckttou, &oldset);
+#endif
/*
* some systems hang hard during the handshake
* if you know why then please let us know
@@ -237,6 +243,12 @@ mkpty(int* master, int* slave)
error(-1, "unable to get standard error window size");
}
#endif
+#ifdef __linux__
+# if !_lib_openpty
+# undef _lib_openpty
+# define _lib_openpty 1
+# endif
+#endif
#if _lib_openpty
if (openpty(master, slave, NULL, ttyp, winp) < 0)
return -1;
@@ -276,6 +288,9 @@ mkpty(int* master, int* slave)
#endif
fcntl(*master, F_SETFD, FD_CLOEXEC);
fcntl(*slave, F_SETFD, FD_CLOEXEC);
+#ifdef __linux__
+ sigprocmask(SIG_SETMASK, &oldset, NULL);
+#endif
alarm(0);
return 0;
}
--- src/cmd/builtin/what.c
+++ src/cmd/builtin/what.c 2012-02-10 17:06:06.262433626 +0000
+++ src/cmd/builtin/what.c 2012-02-13 11:02:18.645933606 +0000
@@ -68,7 +68,7 @@ static struct
int match;
int single;
@ -18,3 +56,39 @@
switch (mid)
{
default:
@@ -122,7 +122,7 @@ what(const char* file, Sfio_t* ip, Sfio_
switch (skip[buf[0]])
{
case HIT:
- if (buf[0] == ')' && s[0] == '@' && s[1] == '(' && s[2] == '#' || buf[0] == ':' && s[0] == '$' && s[1] == 'I' && s[2] == 'd')
+ if (buf[0] == ')' && s[2] == '#' && s[1] == '(' && s[0] == '@' || buf[0] == ':' && s[2] == 'd' && s[1] == 'I' && s[0] == '$')
{
index = 0;
s = buf + 1;
@@ -130,7 +130,7 @@ what(const char* file, Sfio_t* ip, Sfio_
}
break;
case 1:
- if (buf[0] == ')' && s[1] == '@' && s[2] == '(' && buf[1] == '#' || buf[0] == ':' && s[1] == '$' && s[2] == 'I' && s[3] == 'd')
+ if (buf[1] == ')' && buf[0] == '#' && s[2] == '(' && s[1] == '@' || buf[1] == ':' && buf[0] == 'd' && s[2] == 'I' && s[1] == '$')
{
index = 1;
s = buf + 2;
@@ -138,7 +138,7 @@ what(const char* file, Sfio_t* ip, Sfio_
}
break;
case 2:
- if (buf[0] == ')' && s[2] == '@' && buf[1] == '(' && buf[2] == '#' || buf[0] == ':' && s[2] == '$' && s[3] == 'I' && s[3] == 'd')
+
{
index = 2;
s = buf + 3;
@@ -196,7 +196,7 @@ what(const char* file, Sfio_t* ip, Sfio_
list:
if ((s - b) > 2 && *(s - 1) == '$' && *(s - 2) == ' ')
s -= 2;
- if (s > b)
+ if (s > b || !*t)
{
sfprintf(op, "%s%-.*s\n", t, s - b, b);
state.hit = 1;