Page 199 - DCAP602_NETWORK_OPERATING_SYSTEMS_I
P. 199
Unit 10: File System
Now let’s suppose that you have a program that is hopelessly hung (Netscape, maybe) and you notes
want to get rid of it. Here’s what you do:
1. Use the ps command to get the process id (PID) of the process you want to terminate.
2. Issue a kill command for that PID.
3. If the process refuses to terminate (i.e., it is ignoring the signal), send increasingly harsh
signals until it does terminate.
$ ps x
PID TTY STAT TIME COMMAND
2931 pts/5 SN 0:00 netscape
$ kill -SIGTERM 2931
$ kill -SIGKILL 2931
In the example above we used the kill command in the formal way. In actual practice, it is more
common to do it in the following way since the default signal sent by kill is SIGTERM and kill
can also use the signal number instead of the signal name:
$ kill 2931
Then, if the process does not terminate, force it with the SIGKILL signal:
$ kill -9 2931
In addition to the standard development tools used in software development projects, many other
utilities are also helpful. Most of the time these utilities are not directly related to the software
development process but are used as helping aids. Let us introduce to some of these utilities that
are extremely helpful in the software development process. Some of the more common uses of
these utilities are presented and readers are encouraged to experiment with them. If properly
utilized, they may save time and increase productivity.
The indent utility is helpful in implementing a common programming style scheme to all source
code files in a project. The sed utility is useful for searching and replacing text across multiple
files. The diff command is used to display difference between two or more files. The cscope and
cbrowser are used to locate symbols in a software source code tree. The strace and ltrace utilities
are useful to find out system and library calls when a program is executed. GNU binary utilities
are a set of utilities that is often used for different needs.
indent utility
One major objective of every software development project is that the code be well organized,
structured and easy to understand for other members of the team. Proper indentation plays an
important role in achieving these objectives. Most of the editors used in software development
can do automatic indentation if they are configured to do so. The Emacs editor is the best example
as it understands different programming languages and does indentation according to language
rules and style. However you can come across code written by others that is poorly indented and
you may like to re-indent it according to your own requirements or preferences. In large software
development projects, you may try to enforce a particular coding style, but be assured that not
everyone will follow it.
The indent programme is your tool to handle the situation and reformat all files in the project
according to the style adopted for the project. You can do it by creating a script that goes into each
directory of the project and reformats all files. In this section we shall explore some of its features
and how to utilize it. By default, the indent programme uses the GNU style of coding and applies
these rules to input files. It creates a backup file with original contents of the file. The reformatted
file is created with the same name. The backup file ends with a tilde character ~.
LoveLy professionaL university 193