LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices

Reply
 
Search this Thread
Old 11-19-2007, 09:48 PM   #1
cormander
Member
 
Registered: Dec 2004
Location: Hawaii
Distribution: Fedora & CentOS
Posts: 72

Rep: Reputation: 15
Question shell not resizing window


I downloaded / installed a shell wrapper program called 'rootsh':

http://sourceforge.net/projects/rootsh/

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:

Code:
  if (winp == NULL) {
    ioctl(STDIN_FILENO, TIOCGWINSZ, (char *)&currentwinsize);
    winp->ws_row = currentwinsize.ws_row;
    winp->ws_col = currentwinsize.ws_col;
    winp->ws_xpixel = currentwinsize.ws_xpixel;
    winp->ws_ypixel = currentwinsize.ws_ypixel;
  }
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).

If anyone has any insight into this, please help!

Thanks
 
Old 11-19-2007, 10:29 PM   #2
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,123

Rep: Reputation: 151Reputation: 151
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.
 
Old 11-19-2007, 11:13 PM   #3
cormander
Member
 
Registered: Dec 2004
Location: Hawaii
Distribution: Fedora & CentOS
Posts: 72

Original Poster
Rep: Reputation: 15
That doesn't seem to work in this case.
 
Old 11-22-2007, 12:51 PM   #4
cormander
Member
 
Registered: Dec 2004
Location: Hawaii
Distribution: Fedora & CentOS
Posts: 72

Original Poster
Rep: Reputation: 15
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
why mandriva 10.2 gnome2.8 system freezes upon resizing/opening window/new window skaramanger Mandriva 8 08-30-2005 10:22 AM
why mandriva 10.2 gnome2.8 system freezes upon resizing/opening window/new window skaramanger Mandriva 2 08-15-2005 04:38 PM
plz help... resizing a window rksprst General 3 05-19-2005 09:22 PM
Wine: window resizing lifeless_42 Linux - Software 6 09-09-2004 05:55 AM
Fluxbox window resizing hallamigo Linux - Software 4 05-16-2004 11:21 AM


All times are GMT -5. The time now is 12:33 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration