Linux - DesktopThis forum is for the discussion of all Linux Software used in a desktop context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
When I resize the window, rootsh doesn't properly handle things. From what I can tell by doing google searches, a window resize sends the SIGWINCH to the process.
Looking at the C code of rootsh, there's no handle for this signal. But I did find where it appears to be seeting the window characteristics when it launches the slave pty:
I was wondering if anyone knew how to make the appropriate changes to this code so that when a SIGWINCH is recieved, it makes corrections to window sizes?
The main thing that buggs me about this is when I open a window, and then resize it to be bigger, and launch an editor (such as emacs or vi) the area of the editor is small (the origonal window size).
I haven't used rootsh, so this may not help - but I use the checkwinsize option for bash. You can set it with shopt -s checkwinsize either at the prompt or in your ~/.bashrc file. When it's set, bash checks the window size after each command and, if necessary, updates the values of LINES and COLUMNS.
Figured it out, if this helps anyone who has similiar problems. I got the logic flow from reading the source code of the bash shell, and was able to simplify it a bit for this case:
Code:
--- ../src_rpm/orig/rootsh-1.5.2/src/rootsh.c 2005-03-24 06:08:20.000000000 -0700
+++ rootsh-1.5.2/src/rootsh.c 2007-11-21 23:34:39.000000000 -0700
@@ -84,6 +84,7 @@
char *setupshell(void);
int setupusermode(void);
void finish(int);
+void handle_sig_winch(int);
int beginlogging(void);
void dologging(char *, int);
void endlogging(void);
@@ -179,6 +180,8 @@
extern char **environ;
extern int errno;
+volatile sig_atomic_t sigwinch_received;
+
static char progName[MAXPATHLEN];
static char sessionId[MAXPATHLEN + 11];
static int logFile;
@@ -413,6 +416,9 @@
signal(SIGINT, finish);
signal(SIGQUIT, finish);
#endif
+ signal(SIGWINCH, handle_sig_winch);
+ sigwinch_received = 0;
+
newTty = termParams;
/*
// Let read not return until at least 1 byte has been received.
@@ -458,11 +464,19 @@
*/
n = select(masterPty + 1, &readmask, (fd_set *) 0, (fd_set *) 0,
(struct timeval *) 0);
- if (n < 0) {
+ if (n < 0 && sigwinch_received == 0) {
perror("select");
exit(EXIT_FAILURE);
}
+ if(sigwinch_received) {
+ sigwinch_received = 0;
+ signal(SIGWINCH, handle_sig_winch);
+ ioctl(STDIN_FILENO, TIOCGWINSZ, (char *)&winSize);
+ ioctl(masterPty, TIOCSWINSZ, (char *)&winSize);
+ kill(childPid, SIGWINCH);
+ }
+
/*
// The user typed something...
// Read it and pass it on to the pseudo-tty.
@@ -505,6 +519,11 @@
exit(EXIT_SUCCESS);
}
+void handle_sig_winch(int sig) {
+
+ sigwinch_received = 1;
+
+}
/*
// Do some cleaning after the child exited.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.