Two problems with C & ULTRIX
hoffman at hdsvx1.UUCP
hoffman at hdsvx1.UUCP
Thu Jan 22 06:00:27 AEST 1987
Someone please help me with a couple of irritating bugs that have turned up
in a program I wrote. The program produces a constantly refreshed `curses'
display giving the current time & date, a "new mail" flag, a list of
newsgroups with new USENET articles in them, and a list of the current
processes running on the machine, courtesy of `ps -uag'. There is also
a command mode, which one enters via an INTERUPT (^C for me), which allows
one to escape to the shell, rn, or mail, and to reset certain parameters.
My problems:
(1) In command mode, I do a curses `getstr' to pick up a string from the user.
My documentation says that `getstr' terminates with a \n, which is what I
would like to see, but I find that I have to terminate with a \000 (^@)
instead. What am I doing wrong?
(2) I use fork and execl to enter rn, mail or the shell from command mode,
as follows:
shell(location,name)
char *location,*name;
{
int status;
if (!fork())
{
execl (location, name, NULL);
}
wait(&status);
}
where `location' is the actual file name (e.g., "/usr/ucb/mail") and
`name' is the command name (e.g. "mail"). This works great for the
shell (csh) and for rn, but for mail it doesn't appear to do anything.
However, I think it is spawning a process (I can see it in my ps listing).
How do I get to it? Why is mail different from rn and the shell?
(3) For my `ps' display, I use `popen' to start a pipe, and read the lines
from `ps' and then display them. This works fine, but every so often
I get a message "/vmunix: No namelist" followed by either a hangup or
a bus error. Any insights, anyone?
The environment is ULTRIX, Release 2, running on a VAX/750. I will be glad
to send the source code for the whole program (~400 lines) to anyone who
would like to examine it in depth, but I hope that won't be necessary.
--
Richard Hoffman | "They sought it with thimbles, they sought it with care,
Schlumberger WS | They pursued it with forks and hope;
hdsvx1!hoffman | They threatened its life with a railway share,
713-928-4750 | They charmed it with smiles and soap." (L. CARROLL)
More information about the Comp.unix.questions
mailing list