1

I know of the killall5, system V kill command.

Is there something similar where I can send a SIGSTOP to all user processes, a Host OS and guest OS included?

Possibly killall -SIGSTOP??

3
  • to see all the signals kill -l and then see each signal , someone will be there to be used – Ijaz Ahmad Khan Jul 13 '16 at 14:03
  • What do you actually want to accomplish? Do you want to hibernate the system? – Mark Plotnick Jul 13 '16 at 15:12
  • @Mark I want to run application X on one machine and application Y on another machine connected via network. I'd like to send a signal to application Y to halt from application X machine. So that both applications hit a breakpoint at the same time. – user_ABCD Jul 13 '16 at 16:15
1

If you really want to do this, the following, executed by root, will send the STOP signal to everything:

kill -STOP -1

This will screw with you system immensely though, so don't do that.

Specifying -1 as the process ID (from the kill() C library spec in SUSv4):

If pid is -1, sig shall be sent to all processes (excluding an unspecified set of system processes) for which the process has permission to send that signal.

Executed by a user, this will do the same for all processes owned by that user, including the current shell. So don't do that either.

To stop all processes of a particular user, while not being that user (i.e. you are root):

pkill -STOP -u otheruser 

If you execute this with sudo while logged in as otheruser it will still screw you over, so don't do that either.

The only reason I can see for sending STOP to all processes of a user is when that user is a daemon user which is running a very limited number of things.

Also, remember to send CONT later..

1

pkill (see pgrep) is a command-line utility initially written for use with the Solaris 7 operating system. It has since been reimplemented for Linux and some BSDs.

As with the kill and killall commands, pkill is used to send signals to processes. The pkill command allows the use of extended regular expression patterns and other matching criteria.

To signal all the processes of a given user , use:

pkill -signal <signalname> -u <userid>    //(by default it will send SIGTERM)

You can use pgrep with this as a test before you run it to see the process name and pid of what will be signaled:

pgrep  -u  <userid> -l 

You can use any signal (see kill -l) with pkill. see man pkill


Info from man page
pgrep looks through the currently running processes and lists the process IDs which matches the selection criteria to stdout. All the criteria have to match.
For example, pgrep -u root sshd

will only list the processes called sshd AND owned by root. On the other hand,

pgrep -u

root,daemon

will list the processes owned by root OR daemon.

pkill will send the specified signal (by default SIGTERM) to each process instead of listing them on stdout.

Options

-d delimiter Sets the string used to delimit each process ID in the output (by default a newline). (pgrep only.)
-f The pattern is normally only matched against the process name. When -f is set, the full command line is used.
-g pgrp,... Only match processes in the process group IDs listed. Process group 0 is translated into pgrep's or pkill's own process group.
-G gid,... Only match processes whose real group ID is listed. Either the numerical or symbolical value may be used.
-l List the process name as well as the process ID. (pgrep only.)
-n Select only the newest (most recently started) of the matching processes.
-o Select only the oldest (least recently started) of the matching processes. -P ppid,... Only match processes whose parent process ID is listed.
-s sid,... Only match processes whose process session ID is listed. Session ID 0 is translated into pgrep's or pkill's own session ID.
-t term,... Only match processes whose controlling terminal is listed. The terminal name should be specified without the "/dev/" prefix.
-u euid,... Only match processes whose effective user ID is listed. Either the numerical or symbolical value may be used.
-U uid,... Only match processes whose real user ID is listed. Either the numerical or symbolical value may be used.
-v Negates the matching.
-x Only match processes whose name (or command line if -f is specified) exactly match the pattern.
-signal Defines the signal to send to each matched process. Either the numeric or the symbolic signal name can be used. (pkill only.)

1

kill allows the special value -1 for the PID parameter, meaning "all processes (excluding an unspecified set of system processes) for which the process has permission to send that signal", so this should be similar to what a call to killall5 would have done if given the number for the STOP signal:

kill -SIGSTOP -1
1
  • 1
    Sending a signal to -1 is well defined in POSIX. Any kill utility will do. – Kusalananda Jul 13 '16 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.