Home > Articles

This chapter is from the book

Using Signals

Objective:

Clearing frozen processes.

Solaris supports the concept of sending software signals to a process. These signals are ways for other processes to interact with a running process outside the context of the hardware. The kill command is used to send a signal to a process. System administrators most often use the signals SIGHUP, SIGKILL, SIGSTOP, and SIGTERM. The SIGHUP signal is used by some utilities as a way to notify the process to do something, such as re-read its configuration file. The SIGHUP signal is also sent to a process if the remote connection is lost or hangs up. The SIGKILL signal is used to abort a process, and the SIGSTOP signal is used to pause a process. The SIGTERM signal is the default signal sent to processes by commands such as kill and pkill when no signal is specified. Table 5.12 describes the most common signals an administrator is likely to use.

Table 5.12. Signals Available Under Solaris

Signal

Number

Description

SIGHUP

1

Hangup. Usually means that the controlling terminal has been disconnected.

SIGINT

2

Interrupt. The user can generate this signal by pressing Ctrl+C or Delete.

SIGQUIT

3

Quits the process and produces a core dump.

SIGILL

4

Illegal instruction.

SIGTRAP

5

Trace or breakpoint trap.

SIGABRT

6

Abort.

SIGEMT

7

Emulation trap.

SIGFPE

8

Arithmetic exception. Informs a process of a floating-point error.

SIGKILL

9

Killed. Forces the process to terminate. This is a sure kill.

SIGBUS

10

Bus error.

SIGSEGV

11

Segmentation fault.

SIGSYS

12

Bad system call.

SIGPIPE

13

Broken pipe.

SIGALRM

14

Alarm clock.

SIGTERM

15

Terminated. A gentle kill that gives processes a chance to clean up.

SIGUSR1

16

User signal 1.

SIGUSR2

17

User signal 2.

SIGCHLD

18

Child status changed.

SIGPWR

19

Power fail or restart.

SIGWINCH

20

Window size change.

SIGURG

21

Urgent socket condition.

SIGPOLL

22

Pollable event.

SIGSTOP

23

Stopped (signal). Pauses a process.

SIGTSTP

24

Stopped (user).

SIGCONT

25

Continued.

SIGTTIN

26

Stopped (tty input).

SIGTTOU

27

Stopped (tty output).

SIGVTALRM

28

Virtual timer expired.

SIGPROF

29

Profiling timer expired.

SIGXCPU

30

CPU time limit exceeded.

SIGXFSZ

31

File size limit exceeded.

SIGWAITING

32

Concurrency signal reserved by threads library.

SIGLWP

33

Inter-LWP signal reserved by threads library.

SIGFREEZE

34

Checkpoint freeze.

SIGTHAW

35

Checkpoint thaw.

SIGCANCEL

36

Cancellation signal reserved by the threads library.

In addition, you can write a signal handler, or trap, in a program to respond to a signal being sent. For example, many system programs, such as the name server daemon, respond to the SIGHUP signal by re-reading their configuration files. This signal can then be used to update the process while running, without having to terminate and restart the process. Signal handlers cannot be installed for SIGSTOP (23) or SIGKILL (9). Because the process cannot install a signal handler for signal 9, an otherwise well-behaved process may leave temporary files around or not be able to finish out critical operations that it is in the middle of. Thus, kill -9 invites corruption of application data files and should only be used as a last resort.

Here's an example of how to trap a signal in a script:

# trap '/bin/rm tmp$$;exit 1' 1 2 3 15

As the name suggests, trap traps system interrupt until some command can be executed. The previous example traps the signals 1, 2, 3, and 15, and executes the /bin/rm tmp$$ command before exiting the program. The example deletes all tmp files even if the program terminates abnormally.

The kill command sends a terminate signal (signal 15) to the process, and the process is terminated. Signal 15, which is the default when no options are used with the kill command, is a gentle kill that allows a process to perform cleanup work before terminating. Signal 9, on the other hand, is called a sure, unconditional kill because it cannot be caught or ignored by a process. If the process is still around after a kill -9, either it is hung up in the Unix kernel, waiting for an event such as disk I/O to complete, or you are not the owner of the process.

The kill command is routinely used to send signals to a process. You can kill any process you own, and the superuser can kill all processes in the system except those that have process IDs 0, 1, 2, 3, and 4. The kill command is poorly named because not every signal sent by it is used to kill a process. This command gets its name from its most common use—terminating a process with the kill -15 signal.

You can send a signal to a process you own with the kill command. Many signals are available, as listed in Table 5.12. To send a signal to a process, first use the ps command to find the process ID (PID) number. For example, type ps -ef to list all processes and find the PID of the process you want to terminate:

# ps -ef

UID   PID  PPID  C    STIME  TTY  TIME  CMD
root    0     0  0   Nov 27  ?    0:01  sched
root    1     0  0   Nov 27  ?    0:01  /etc/init -
root    2     0  0   Nov 27  ?    0:00  pageout
root    3     0  0   Nov 27  ?   12:52  fsflush
root  101     1  0   Nov 27  ?    0:00  /usr/sbin/in.routed -q
root  298     1  0   Nov 27  ?    0:00  /usr/lib/saf/sac -t 300
root  111     1  0   Nov 27  ?    0:02  /usr/sbin/rpcbind
root  164     1  0   Nov 27  ?    0:01  /usr/sbin/syslogd -n -z 12
root  160     1  0   Nov 27  ?    0:01  /usr/lib/autofs/automountd
.
.
.
root 5497   433  1 09:58:02  pts/4  0:00  script psef

To kill the process with a PID number of 5497, type this:

# kill 5497

Another way to kill a process is to use the pkill command. pkill functions identically to pgrep, which was described earlier, except that instead of displaying information about each process, the process is terminated. A signal name or number may be specified as the first command-line option to pkill. The value for the signal can be any value described in Table 5.12. For example, to kill the process named psef with a SIGKILL signal, issue the following command:

# pkill -9 psef

In addition, the Desktop Process Manager, which was described earlier, can be used to kill processes. In the Process Manager window, highlight the process that you want to terminate, click Process from the toolbar at the top of the window, and then select Kill from the pull-down menu, as shown in Figure 5.9.

Figure 5.9

Figure 5.9 Killing processes.

The equivalent Unix command used by the Process Manager to terminate a process is shown here:

# kill -9 <PID>

<PID> is the process ID of the selected process.

The preap command forces the killing of a defunct process, known as a zombie. In previous Solaris releases, zombie processes that could not be killed off remained until the next system reboot. Defunct processes do not normally impact system operation; however, they do consume a small amount of system memory. See the preap manual page for further details of this command.

Pearson IT Certification Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from Pearson IT Certification and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about Pearson IT Certification products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites; develop new products and services; conduct educational research; and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by Adobe Press. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.pearsonitcertification.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020