general
-
X
-
SOCS
-
defaults and misc
General Computing Tips::
Oddities and Troubleshooting
Vincent Stephen-Ong
It is important to note that the entirety of this section really
expects that you have some Unix and/or X literacy, especially for
the why it works explanations.
General Oddities
There are a couple of things that are generally odd about the way
things work on the systems available at SOCS, particularly on the Unix machines if you are not
used to their idiosyncrasies
-
gcc Optimization Problems
"I'm compiling perfectly good C code and I'm not getting the
expected results!"
-
symptoms:
-
You write a C program, compile it unoptimized (i.e.:
with no special command-line arguments), and it
works fine. You then recompile the program with
optimizations (e.g.:
gcc -O2
) and it
stops working, core dumps, or otherwise screws up.
-
examples:
-
#include <stdio.h>
main() {
int i;
for (i=1;i<32;i++)
;
printf("%d\n", i);
}
-
#include <stdio.h>
#include <stdlib.h>
#define N 8
struct node {
struct node*next;
};
static struct node *first;
static struct node nodes[N];
int main (void)
{
struct node **p;
int i;
p = &first;
for (i=0; i<N; i++) {
*p = nodes + i;
p = &nodes[i].next;
/* rand (); */ /* uncomment this line and it works */
}*p = NULL;
puts (first==nodes
? "this is what I expected"
: "what is going on here?");
return 0;
}
-
solutions:
-
Obviously, if you compile with no optimizations, you
won't have this problem, but this isn't really a
viable alternative.
-
The gcc 2.8.x line is known to have many, many bugs,
especially in its optimizer. If you really need a C++
compiler, try egcs.
-
Try compiling with "
-O
" only or add the
"-fno-strength-reduce
" flag; it might
solve the problem.
-
Switch or downgrade to a compiler in the gcc 2.7.x
line, it has much fewer bugs, although the
-O2
bug
does seem to affect it in case #2.
It seems that using
-fno-strength-reduce
is a good idea,
in general.
-
additional notes:
-
Obviously this is a bit of a more technical
issue... Some things you might want to know are:
-
How to check which version of gcc I'm using:
% gcc --version
-
How exactly should I be compiling stuff?
Well, if you're compiling unoptimized code,
then you won't have any problems. The
correct syntax is:
% gcc filename.c
If you're compiling optimized code, the best
way to avoid these problems (if you can't
switch compilers) is:
% gcc -O -fno-strength-reduce filename.c
-
Backspace vs Delete
"My Backspace key doesn't work!"
or
"My Delete key doesn't work!"
or
"Why the hell do Backspace and Delete act so damn weird?"
-
symptoms:
-
You hit backspace, and it doesn't give you what you
expected. Or, you hit delete, and it doesn't give
you what you expected. By "not what you expected"
I mean that it either deleted the wrong character,
didn't do anything, or produced a weird garbage
character (like "^H") on the screen.
-
examples:
-
At the prompt, type a bunch of stuff, and move the
cursor to somewhere in the middle of the text.
Next, hit the Backspace key a few times, watch what
happens, then hit the Delete key a few times (and
watch what happens).
-
ytalk someone and try hitting Backspace and
Delete and see what happens.
-
Frustrating, isn't it?
-
solutions:
-
Try adding
stty erase ^h
to your login script.
-
Try adding
keycode 14 = BackSpace
keycode 111 = Delete
to your .loadkeys and make sure
loadkeys ~/.loadkeys
is in your login script.
-
Try adding
keycode 22 = Delete
keycode 107 = BackSpace
to your .xmodmap and make sure
xmodmap ~/.xmodmap
is in your .xinitrc and/or
.xsession
-
If you use emacs, add these lines to your
.emacs:
;; for X
(cond (window-system
(global-set-key [delete] 'delete-char)
(global-set-key [backspace] 'backward-delete-char)
))
;; for non-X
(cond ((equal window-system nil)
(global-set-key [(control h)] 'backward-delete-char)
))
-
why it works:
-
The deal is (basically) that way back when, DEL
(delete) was
used to mean ignore-this-character. DEC took it to
mean erase-the-previous-character, and put the DEL
key on top of the <entergt; key on VTx00
terminals. IBM on the PC but backspace (C-H).
It's a godawful mess, and one of the worst things
about UNIX, IMHO.
Thanks to Louis Raphael
for this explanation.
In other words, there were two different standards
established at to what "the key above <enter>"
should do and this inconsistency is still present in
Unix.
-
The stty line says to treat the Ctrl-H
keysequence as meaning "erase".
-
The loadkeys solution only works at the
console and it physically assigns the keys "14" and
"111" to delete and backspace in the appropriate
way.
This is the console equivalent of
xmodmap.
-
The xmodmap solution only works under X and it
physically assigns the keys "22" and "107" to delete
and backspace so that "the key above <enter>"
deletes the character before the cursor, and
<delete> deletes the current character.
This is the X
equivalent of loadkeys.
-
The emacs solution applies only for
emacs, naturally. It sets the
<delete> and <backspace> keys
appropriately under X.
Unfortunately, it is impossible, at the console, to
tell the difference between a C-h and "the key above
<enter>" since "the key above <enter>"
sends C-h. As a result, we rebind C-h to
backward-delete-char. This means that if
you want the "usual" C-h functionality (help),
you'll have to either rebind it to something else or
invoke it via M-x help.
-
XON/XOFF (Flow Control)
"In one of my xterms (or the console), the keyboard won't
respond!"
-
symptoms:
-
Your keyboard stopped responding to keypresses in
one of your xterms. You may have previously hit a
bunch of (random) keys.
-
examples:
-
Hit <Ctrl>-S. Now, try and type stuff.
You'll find that nothing appears on your screen.
-
solutions:
-
why it works:
-
In software handshaking protocols, it is necessary
to transmit extra data in order to control the
sending and receiving of data along a channel.
In an xterm and at the console, <Ctrl>-S sends
the "XOFF" signal which, appropriately, signals a
stop of character/data transmission
("XOFF"="xfer off"="transfer off").
Symmetrically, <Ctrl>-Q sends the "XON" signal
which signals resumption of output.
-
Filenames with special characters
"I can't view/edit/delete/access this weirdly-named file!"
-
symptoms:
-
You cannot view, edit, delete, or in anyway access a
certain file. Error messages can be quite diverse.
-
examples:
-
solutions:
-
If your shell supports automatic filename completion,
try using that. (Type the first few letters of the
file name, then hit <Tab> or <Esc>)
-
Try typing the name of the file enclosed in double
quotes (").
-
Try placing a forward slash "\" in front of
"strange" characters, and enclosing the resulting
name in double quotes (").
-
why it works:
-
Certain special characters are assigned special
meaning in different Unix shells.
When these characters appear in a file name, you
have to specially indicate that they are to be
treated literally (and not given their special
meaning).
In the above example, the < and > signs are
usually used for input and output redirection.
Since they appear in the filename, you must tell the
shell to treat them literally. Different shells
have different mechanisms for this, but successfully
read the file in the above example with either:
% less "<test>"
or
% less \<test\>"
under all of tcsh, csh, and
bash.
X-Windows Oddities
X can sometimes be a bit of a
temperamental beast; here a few taming tips.
-
Fuzzy screens
"My screen is all fuzzy and out of focus!"
-
symptoms:
-
The screen is fuzzy and out of focus.
-
solutions:
-
why it works:
-
Not sure really. It probably has something to do
with an slightly incorrectly-specified monitor
refresh rate in the X-Windows configuration, but
we're not sure.
SOCS Oddities
There are a few things that you will find, over the course of your
time at SOCS,
don't quite operate the way you might expect or that operate
in a way that is peculiar to SOCS. The
purpose of this section is to save you some frustration and point them
out for you ahead of time.
-
Missing C function prototypes on SOCS' SunOS 4
machines
"My C code is perfectly good but the compiler keeps complaining!"
-
symptoms:
-
You compile perfectly good C code with the
-Wall option and you
encounter a number of
warning messages
regarding
implicit declarations.
The compile succeeds anyway
and the program seems to work.
-
You try compile perfectly good C code you a encounter a
number of
error messages
regarding
undeclared identifiers. The compilation
fails.
-
Some combination of the above.
-
examples:
-
Given this classic C program (line numbers added):
1 #include <stdio.h>
2 #include <stdlib.h>
3
4 int
5 main(int argc, const char *argv[])
6 {
7 printf("Hello world!\n");
8
9 return EXIT_SUCCESS;
10 }
-
Attempts to compile it on a SunOS machine, result in
the following response from gcc (on lisa):
[lisa] [/u3/ugrad/zibalatz/tmp/test] gcc -Wall helloworld.c
helloworld.c: In function `main':
helloworld.c:7: warning: implicit declaration of function `printf'
helloworld.c:9: `EXIT_SUCCESS' undeclared (first use this function)
helloworld.c:9: (Each undeclared indentifier is reported only once
helloworld.c:9: for each function it appears in.)
helloworld.c:10: warning: control reaches end of non-void function
-
solutions:
-
-
Download protos.h.
-
Rename it (if it isn't already) to
protos.h.
-
Copy or move it to the directory that contains
your C program.
-
In your C program's source file, include a
line at the top of your program that reads:
#include "protos.h"
-
Add additional function prototypes and/or
macro definitions as necessary. You can use
the man pages to find out what the correct
function prototype should be.
-
Compile under another platform (such as one of the
Linux
Pentiums). This will only work if your
program does not rely on libraries or
architectural considerations that would necessitate
the use of a SunOS machine.
-
why it works:
-
SOCS'
SunOS 4 machines are missing
several key function prototypes and macro
declarations. This is believed to be a bug in
SunOS4.
-
implicit declaration
means that gcc did not find a
function prototype for a function that is being used.
In the example, it complains because
it could not find a function
prototype for printf().
Hence, the function is declared implicitly (as
opposed to explicitly in the form of a
function prototype).
-
undeclared identifier
means that gcc encountered a
non-function token which it did not recognize. It
assumes that it is an identifier (variable name, label
name) of some kind but that you did not declare it.
In the example, it complains because it could not find
the declaration of EXIT_SUCCESS.
-
protos.h
provides some but not all of the missing prototypes.
You will still encounter the occasional warning message.
Add your own function prototypes (with the extern
prefix) to this file as you encounter them. You can check
the man pages for the
functions which generate warnings in
order to figure out what their prototypes should be.
-
Getting automatically logged out from your
machine after a certain amount of idle time
"I logged into a machine, went for lunch, and when I came back, I was
logged out!"
-
symptoms:
-
After a certain amount of time idle on a machine, all of your
applications close and you are returned to the
xdm login screen.
-
solutions:
-
This is not a bug. Don't stay idle for excessive amounts of
time. If you are going to physically occupy a machine, then
make use of it.
-
why it works:
-
Getting automatically logged out from your machine
suddenly and for no apparent reason
"I was in the middle of typing and suddenly I got logged out!"
-
symptoms:
-
You are not idle and may be in the middle of typing or
doing other work when suddenly all your applications
close and you are returned to the xdm login
screen.
-
solutions:
-
This is a bug, and we don't know why it happens. If you do,
please contact systems staff.
-
why it works:
-
Nobody knows- it must be a bug somewhere, someplace, but we
don't know what it is. It is not related to the
above-mentioned auto-logout feature.
-
Attempts to login to a Pentium with a full
quota
"My quota is full and I can't login to a Pentium!"
-
symptoms:
-
Your disk quota is full and you cannot login to a
Pentium.
-
solutions:
-
Login from a terminal or
other remote location and either delete enough files
to drop below quota, or move them to secondary
storage (i.e.: zip or floppy disk), or compress them
using gzip or compress.
-
A good place to look for wasted space is in
~/.netscape/cache This is where your Netscape
cache is stored and it can be safely purged.
-
why it works:
-
When your quota is full, you will not be allowed to
login to a Pentium. This is not a bug; it is an
intended feature of the SOCS systems.
-
The newsreader tin
displays user's email address with two @ signs instead of
one
"Why is tin garbling my email address?"
-
symptoms:
-
All the messages you post with tin
contain a mangled version of
your email address. Specifically, there are two @ signs
instead of one.
-
examples:
-
If my user name is ncc, posts made with
tin appear to be signed by
ncc@@cs.mcgill.ca
-
solutions:
-
why it works:
-
This bug seems to occur only for a few users. It happens to
Nick Cabatoff, for
instance, but it doesn't happen to me
(Vincent
Stephen-Ong). We don't know why it happens, or how to
solve it. Consider it a feature since it means
spammers
will have a harder time reaching you!
SOCS Defaults and Miscellaneous Issues
It is quite useful to be aware of what the default configuration files
are and where they are located on the SOCS systems.
-
Shell Configuration
"Why does tcsh/bash/csh not operate the way I expect it
to?"
or
"Where can I find examples of shell configuration/startup
files?"
-
For tcsh:
/usr/socs/Cshrc
is the default .cshrc
/usr/socs/Login
is the default .login
-
For bash:
/usr/socs/Profile
is the default .profile, but it is not available on all
machines. You may want to keep a copy in your home
directory and source it when you can't find the global
one.
-
Emacs Configuration
"Why do I get this weird behaviour from emacs despite my
.emacs settings?"
or
"Where can I find examples of emacs configuration?"
-
By default, emacs always runs the
default.el file before it runs your .emacs if it
can find it in its load path.
On the SOCS
systems, this is located at:
/usr/local/lib/emacs/site-lisp/default.el
You can easily override this with a few command-line
options. I would recommend aliasing emacs to:
emacs -q -l ~username/.emacs
if you don't want the SOCS default.el to
be loaded.
-
X-Windows Configuration
"What happens when X
starts up?"
-
FVWM and TWM Configuration
"What happens when FVWM or TWM or TVTWM starts up?"