sysvinit/showconsole-1.09.dif

100 lines
2.9 KiB
Plaintext

--- blogd.c
+++ blogd.c 2008-06-13 13:30:56.867756846 +0200
@@ -220,10 +220,12 @@ int main(int argc, char *argv[])
{
int fd, fd2, flags;
int ptm, pts, cntrtty = 1;
- pid_t pid, ppid = getppid();
+ const pid_t ppid = getppid();
+ const pid_t pgrp = getpgid(ppid);
char ptsname[NAME_MAX+1];
struct termios t;
struct winsize w;
+ pid_t pid;
time_t tt;
char *stt, *name = ttyname(0);
@@ -276,7 +278,7 @@ int main(int argc, char *argv[])
if (!w.ws_row)
w.ws_row = 24;
if (!w.ws_col)
- w.ws_row = 80;
+ w.ws_col = 80;
fd2 = -1;
do {
@@ -337,6 +339,7 @@ int main(int argc, char *argv[])
dup2(ptm, 0);
dup2(fd, 1);
dup2(fd, 2);
+ close(pts);
close(ptm);
if (fd > 2)
close(fd);
@@ -362,7 +365,7 @@ int main(int argc, char *argv[])
exit(0);
}
pidfile();
- prepareIO(reconnect, 0, 1, fd2);
+ prepareIO(reconnect, pgrp, 0, 1, fd2);
while (!signaled)
safeIO();
@@ -380,9 +383,6 @@ int main(int argc, char *argv[])
close(1);
(void)tcflush(2, TCOFLUSH);
close(2);
-
- (void)tcflush(pts, TCIOFLUSH);
- close(pts);
(void)tcflush(0, TCIFLUSH);
close(0);
rmfpid();
--- libconsole.c
+++ libconsole.c 2008-06-13 13:38:25.436903735 +0200
@@ -724,10 +724,12 @@ static void *action(void *dummy)
* Prepare I/O
*/
static const char *fifo_name = _PATH_BLOG_FIFO;
+static pid_t pgroup = -1;
-void prepareIO(void (*rfunc)(int), const int in, const int out, const int second)
+void prepareIO(void (*rfunc)(int), const pid_t pgrp, const int in, const int out, const int second)
{
vc_reconnect = rfunc;
+ pgroup = pgrp;
fdread = in;
fdwrite = out;
fdsec = second;
@@ -778,9 +780,19 @@ static void more_input (struct timeval *
if (FD_ISSET(fdread, &watch)) {
const ssize_t cnt = safein(fdread, (char*)trans, sizeof(trans));
+ static struct winsize owz;
+ struct winsize wz;
if (cnt > 0) {
- parselog(trans, cnt); /* Parse and make copy of the input */
+ if (ioctl(fdwrite, TIOCGWINSZ, &wz) == 0) {
+ if (memcmp(&owz, &wz, sizeof(struct winsize))) {
+ ioctl(fdread, TIOCSWINSZ, &wz);
+ (void)memcpy(&owz, &wz, sizeof(struct winsize));
+ if (pgroup > 1)
+ killpg(pgroup, SIGWINCH);
+ }
+ }
+ parselog(trans, cnt); /* Parse and make copy of the input */
safeout(fdwrite, (char*)trans, cnt); /* Write copy of input to real tty */
(void)tcdrain(fdwrite);
--- libconsole.h
+++ libconsole.h 2008-06-13 13:31:59.302034490 +0200
@@ -2,6 +2,6 @@ extern void pushd(const char * path);
extern void popd(void);
extern char * fetchtty(const pid_t pid, const pid_t ppid, unsigned int *mjmi);
extern char * secondtty(char * compare);
-extern void prepareIO(void (*rfunc)(int), const int in, const int out, const int second);
+extern void prepareIO(void (*rfunc)(int), const pid_t pgrp, const int in, const int out, const int second);
extern void safeIO (void);
extern void closeIO(void);