Sponsored Content
Full Discussion: Signal Processing
Top Forums UNIX for Dummies Questions & Answers Signal Processing Post 8202 by Perderabo on Monday 8th of October 2001 10:19:26 AM
Old 10-08-2001
Gee, thanks for the kind words guys!

No, you cannot just assume the next pid will be the current pid +1. You're on a multi-user machine. Stuff like cron runs all the time. If someone else forks first, they get the next pid. Also in a multi-cpu system, each cpu will usually reserve a chunk of 10 or so pids at once to cut down on spinlocks. Finally, pids recycle after pid 32,000.

The worst consequence of the sleep program in the background is that it is consuming a proc table entry. Too many of these and eventually you bump into maxuprc and cannot fork anymore. As long as that was not an issue, I'd just let it run. Remember that it will take code to remember or find the pid and then kill the pid. The load that this code would put on the system is trivial, but the only payback is the early death of a sleep statement...it can't make a profit.

If you really got to nail that last sleep process, a "kill $(ps -f | grep [s]leep |awk '{print $2}')" should get it.
 

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script Signal Processing

I am trying to develop a script that will properly handle kill signals particularly kill -2. I have program (_progres) that properly receives the signal if I run it from the command line directly: _progres -T /tmp -p /home/mejones/signal.p -b 2>&1 & If I try to put it in a script (i.e.... (2 Replies)
Discussion started by: mejones99
2 Replies

2. Programming

Signal processing

We have written a deamon which have many threads. We are registering for the SIGTERM and trying to close main thread in this signal handling. Actually these are running on Mac OS X ( BSD unix). When we are unloading the deamon with command launchctl, it's sending SIGTERM signal to our process... (1 Reply)
Discussion started by: Akshay4u
1 Replies

3. Programming

alarm signal processing

I'm writing a function right now, and I want to set an alarm to avoid a timeout, here's the general idea of my code: int amt = -2; alarm(10); amt = read(fd, &t->buf, TASKBUFSIZ - tailpos); //do a read when the alarm goes off, i want to check the value of "amt" ... (1 Reply)
Discussion started by: liaobert
1 Replies

4. Solaris

Signal Processing in unix

I've read the man page of singal(3) but I still can't quite understand what is the difference between SIGINT, SIGALRM and SIGTERM. Can someone tell me what is the behavioral difference among these 3 signals in kill command? Thanks! (2 Replies)
Discussion started by: joe228
2 Replies

5. Shell Programming and Scripting

How to make parallel processing rather than serial processing ??

Hello everybody, I have a little problem with one of my program. I made a plugin for collectd (a stats collector for my servers) but I have a problem to make it run in parallel. My program gathers stats from logs, so it needs to run in background waiting for any new lines added in the log... (0 Replies)
Discussion started by: Samb95
0 Replies

6. Programming

awk processing / Shell Script Processing to remove columns text file

Hello, I extracted a list of files in a directory with the command ls . However this is not my computer, so the ls functionality has been revamped so that it gives the filesizes in front like this : This is the output of ls command : I stored the output in a file filelist 1.1M... (5 Replies)
Discussion started by: ajayram
5 Replies

7. Shell Programming and Scripting

Continue Processing after a signal is caught

Is it possible to continue after signal is caught and control goes to function specified in the trap statement? (3 Replies)
Discussion started by: Soham
3 Replies
CPUSET(1)						    BSD General Commands Manual 						 CPUSET(1)

NAME
cpuset -- configure processor sets SYNOPSIS
cpuset [-l cpu-list] [-s setid] cmd ... cpuset [-l cpu-list] [-s setid] -p pid cpuset [-c] [-l cpu-list] -C -p pid cpuset [-c] [-l cpu-list] [-j jailid | -p pid | -t tid | -s setid | -x irq] cpuset -g [-cir] [-d domain | j jailid | -p pid | -t tid | -s setid | -x irq] DESCRIPTION
The cpuset command can be used to assign processor sets to processes, run commands constrained to a given set or list of processors, and query information about processor binding, sets, and available processors in the system. cpuset requires a target to modify or query. The target may be specified as a command, process id, thread id, a cpuset id, an irq, a jail id, or a NUMA domain. Using -g the target's set id or mask may be queried. Using -l or -s the target's CPU mask or set id may be set. If no target is specified, cpuset operates on itself. Not all combinations of operations and targets are supported. For example, you may not set the id of an existing set or query and launch a command at the same time. There are two sets applicable to each process and one private mask per thread. Every process in the system belongs to a cpuset. By default processes are started in set 1. The mask or id may be queried using -c. Each thread also has a private mask of CPUs it is allowed to run on that must be a subset of the assigned set. And finally, there is a root set, numbered 0, that is immutable. This last set is the list of all possible CPUs in the system and is queried using -r. When running a command it may join a set specified with -s otherwise a new set is created. In addition, a mask for the command may be speci- fied using -l. When used in conjunction with -c the mask modifies the supplied or created set rather than the private mask for the thread. The options are as follows: -C Create a new cpuset and assign the target process to that set. -c The requested operation should reference the cpuset available via the target specifier. -d domain Specifies a NUMA domain id as the target of the operation. -g Causes cpuset to print either a list of valid CPUs or, using -i, the id of the target. -i When used with the -g option print the id rather than the valid mask of the target. -j jailid Specifies a jail id as the target of the operation. -l cpu-list Specifies a list of CPUs to apply to a target. Specification may include numbers separated by '-' for ranges and commas sepa- rating individual numbers. A special list of ``all'' may be specified in which case the list includes all CPUs from the root set. -p pid Specifies a pid as the target of the operation. -s setid Specifies a set id as the target of the operation. -r The requested operation should reference the root set available via the target specifier. -t tid Specifies a thread id as the target of the operation. -x irq Specifies an irq as the target of the operation. EXIT STATUS
The cpuset utility exits 0 on success, and >0 if an error occurs. EXAMPLES
Create a new group with CPUs 0-4 inclusive and run /bin/sh on it: cpuset -c -l 0-4 /bin/sh Query the mask of CPUs the <sh pid> is allowed to run on: cpuset -g -p <sh pid> Restrict /bin/sh to run on CPUs 0 and 2 while its group is still allowed to run on CPUs 0-4: cpuset -l 0,2 -p <sh pid> Modify the cpuset /bin/sh belongs to restricting it to CPUs 0 and 2: cpuset -l 0,2 -c -p <sh pid> Modify the cpuset all threads are in by default to contain only the first 4 CPUs, leaving the rest idle: cpuset -l 0-3 -s 1 Print the id of the cpuset /bin/sh is in: cpuset -g -i -p <sh pid> Move the pid into the specified cpuset setid so it may be managed with other pids in that set: cpuset -s <setid> -p <pid> Create a new cpuset that is restricted to CPUs 0 and 2 and move pid into the new set: cpuset -C -c -l 0,2 -p <pid> SEE ALSO
cpuset(2) HISTORY
The cpuset command first appeared in FreeBSD 7.1. AUTHORS
Jeffrey Roberson <jeff@FreeBSD.org> BSD
January 8, 2015 BSD
All times are GMT -4. The time now is 11:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy