LINUX NEWS
RESOURCES & LINKS FROM BRAINBUZZ.COM
Thursday, June 28, 2001
Read By Over 6,000 Linux Enthusiasts Weekly!
TABLE OF CONTENTS
1) Sean’s Notes
2) Linux News
Loki MPEG Player Update
RedHat Enters Database Market
Putting a Bad API on a Good OS
BOFH Meets the Linux Evangelist
3) Linux Resources
SAIR Linux Security Certification
Linux on the Desktop: A Guide For Windows Users
Installing a Custom Kernel
Fundamentals of Multithreading
The CGI Bin
4) App o’ the week
~~~~~~~~~~~~~~~~~~~~~~ ADVERTISEMENT ~~~~~~~~~~~~~~~~~~~~~~~
Award Winning Java2 Training Available Online Now! Do your beans all fall properly in place? Do you have the Java skills you need? Online training is the most intelligent way to learn what you need to know when you need to know it! Get all 15 Dynamic Java courses for just $1,225 or buy the courses individually. This package is normally priced at $1,595.
http://ad.brainbuzz.com/?RC06&AI345
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For information on how to advertise in this newsletter please contact mailto:adsales@BrainBuzz.com or visit http://cramsession.brainbuzz.com/marketing/default.asp
1) Sean’s Notes
It’s been a while since we looked at some of the stuff that goes on behind the scenes. This week, we’re getting back into it by brushing up on signals.
Signals are messages that are sent to a process. Messages might be from you (quit), or from the kernel itself (hey, you just stomped on someone else’s memory!). In the Windows world, programs cycle around an event loop. In UNIX, they are allowed to go on their merry way, but can optionally trap certain signals. Signals have a default action, so if the app doesn’t trap the signal, it may continue as normal, or perhaps be stopped by the system.
You’re probably already familiar with signals, if you’ve ever done:
kill 1234
killall -HUP named
then you’ve sent signals to processes. The first example sends the SIGTERM signal to process 1234, which will cause it to stop execution. The second sends the SIGHUP signal to all the named processes. Uncaught, SIGHUP (hangup) will also cause the application to terminate, but common usage is to trap it and cause the application to re-read its configuration files. There are about 30 signals used in Linux, but you’ll only need to know a few of them.
To give you an idea of how this all operates, I’m going to have to write some code. If you want to follow along with me, you can call this t1.c.
/* Program execution starts here */
int main (void) {
printf("My PID is %d\n", getpid());
while (1) {
printf("Good night!\n");
sleep(10);
printf("Good morning!\n");
}
}
Compile this with:
gcc t1.c -o t1
which will create an executable called t1. In C, execution starts in the main() function. The code prints it’s current processid, and then enters an infinite loop. Run the program:
./t1
and you’ll see that you get “Good night!”, a 10 second pause (that’s the sleep() function in action), followed by “Good morning!”, then it repeats.
Still with me? Pop open a new window, and send a HUP signal to the process. If you saw:
My PID is 21317
then in your other window you’ll type:
kill -HUP 21317
On my screen, I get:
$ ./t1 My PID is 21317 Good night! Hangup $
So, even though the program never had any logic to get out of that infinite loop, the operating system terminated the process (and wrote “Hangup”). Let’s catch that signal now. Call this file t2.c:
#include <signal.h>
/* This is the signal handler */
void handler(int signum) {
printf("Inside handler (signal %d)\n", signum);
}
/* Program execution starts here */
int main (void) {
printf("My PID is %d\n", getpid());
signal(SIGHUP, &handler);
while (1) {
printf("Good night!\n");
sleep(10);
printf("Good morning!\n");
}
}
The first line imports all the definitions for the signal handling functions. The next few lines define a signal handler, simply called “handler”. A signal handler has a known form – it can return nothing, and accepts an integer (signal.h has all that stuff in there). Inside handler, I simply print out the value of that integer, and return. The last difference is that I call the signal() function before I start the loop, which associates the signal (SIGHUP) with my handler. Build the program and then run it:
$ gcc t2.c -o t2 $ ./t2 My PID is 21343 Good night!
Send the HUP signal again, and see what happens:
$ kill -HUP 21343
Inside handler (signal 1) Good morning!
and execution continues. Why? t2.c caught the HUP signal, and decided to continue execution. You can kill it by sending a TERM (actually, that’s the default) signal to it:
$ kill 21343
Terminated
In fact, there is no reason we can’t capture SIGTERM and ignore it, though in practice we would want to exit gracefully instead of just dying. To make sure that people don’t do stuff like that, some signals can not be ignored, such as SIGKILL. SIGKILL is a heavy handed version of SIGTERM, it has signal number 9, and you can do stuff like…
kill -9 21343 kill -KILL 21343
…to get rid of that process that just won’t die. I use this one a lot on Netscape:
killall -9 netscape-navigator
because sometimes it just hangs and there is no way to get rid of it.
There are some processes that can’t be killed with good ol’ signal 9, these are called “zombies”. I won’t get into what a zombie is today, but they show up on a “ps -ef” with the word zombie on the line. To get rid of those, you have to kill its parent (third column in the ps listing).
You can get a list of all the signals through the signal(7) man page:
man 7 signal
Those interested in learning more about this kind of stuff should pick up “UNIX Network Programming” by W Richard Stevens. A necessity if you’re going to get into network programming, and inter-process communications.
Long live the Penguin,
Sean mailto:swalberg@brainbuzz.com
Visit the Linux News Board at http://boards.brainbuzz.com/boards/vbt.asp?b2
2) Linux News
Loki MPEG Player Update
Loki, the porters of many fine games, developed an MPEG library a while ago to handle playback of movies. This most recent update fixes a bunch of bugs and adds some features. If you’re looking for an MPEG player, here is a great start.
http://www.lokigames.com/development/smpeg.php3
RedHat Enters Database Market
RedHat, “the leader in developing, deploying and managing open source solutions, today announced Red Hat Database. The Red Hat Database product is an open source database solution, based on PostgreSQL 7.1, and optimized with Red Hat Linux 7.1, for mid-sized organizations and corporate workgroups and departments.”
http://www.redhat.com/databasesolution
Putting a Bad API on a Good OS
Some might say that OS/2’s WIN32 compatibility was part of its downfall since it offered vendors no incentive to target it specifically. So, are projects like WINE, which implement the WIN32 API under Unix, doing the same?
http://www.osopinion.com/perl/story/11297.html
BOFH Meets the Linux Evangelist
Everyone’s favourite system administrator, the BOFH, matches wits with a luser…I mean user…who doesn’t quite get the hang of his new Linux system. “Where’s Word?” he asks. See how the BOFH handles this call.
http://www.theregister.co.uk/content/30/19898.html
3) Linux Resources
SAIR Linux Security Certification
If you were looking to write the SAIR Linux Security exam, you’d be wise to check out Brainbuzz user ironpaw’s view. He wrote the exam and was, shall we say, less than impressed.
http://boards.brainbuzz.com/boards/vbm.asp?m13946
Linux on the Desktop: A Guide For Windows Users
This article (watch out for line wrapping in the URL) is a nice little introduction on what has to be done when installing a desktop version of Linux, and what you can expect. Those that have done it once or twice might find their time better spent elsewhere, but for the complete newbie it’s a worthwhile read.
http://www.extremetech.com/article/0,2299,s%253D1028%2526a%253D5549 ,00.asp
Installing a Custom Kernel
Though I wrote about this topic a while back, this article puts the whole process of kernel compilation and installation into a nice stepped process. It is geared toward the people who are recompiling the existing kernel, instead of doing an upgrade, so take some extra care if you’re doing the latter.
http://www.linux.com/develop/newsitem.phtml?sid=1&aid439
Fundamentals of Multithreading
Threads are otherwise known as light weight processes, they are one of the methods that allow applications to take advantage of multi-processor machines. Within this article, a lot of threading and MP topics are examined. Warning - this article gets pretty technical.
http://www.systemlogic.net/articles/01/6/multithreading/
The CGI Bin
CGI, the Common Gateway Interface, allows a web server to interact with other processes to produce dynamic web pages. This site has several tutorials that introduce you to the topic using some pretty handy examples.
http://www.thecgibin.com/
4) App o’ the week
This looks like a handy one…If your server is so locked up that you can’t log in to fix things, but can still be pinged, this kernel patch will let you send a special ping to reboot. Don’t worry, there is a password mechanism in place!
http://nail.itapac.net/ricmp/
(C) 2001 BrainBuzz.com. All Rights Reserved.
This message is from BrainBuzz.com.
You are currently subscribed to the Hottest Linux News and Resources as: sean@ertw.com
To un-subscribe from this newsletter by e-mail: send a blank email message to: mailto:leave-linuxnews-3825955Y@list.cramsession.com
To Subscribe to this newsletter by e-mail: send a blank email message to: