signals to running processes

James Logan III logan at vsedev.VSE.COM
Thu Dec 1 10:18:22 AEST 1988


In article <950 at taux01.UUCP> cjosta at taux01.UUCP (Jonathan Sweedler) writes:
# I have a program that takes a long time to finish running.  From time
# to time (sometimes never, sometimes more frequently) I would like to
# find out the current status.  The way I accomplish this is to send one
# of the user defined signals (SIGUSR1 - no. 30) to the process.  The
                                             ^^
SIGUSR1 is 16 under System V, so you either made a typo or you're
using a BSD system.  MY RESPONSE WILL NOT HELP YOU IF YOU USE
BSD UNIX, but it may give people in this newsgroup some good ideas.  

# 1) Is there any way for someone who is not the owner of a process to
# send the process a signal?

Not without being root or you.  Writing a setuid program would work, but
is rather clumsy.

# 2) Or, is there another way for a random user to cause a program to
# asynchronously print out a status report (or perform some action) once
# it has started running?

Yes, use shared memory.  Just use shmget(2) to get a hunk of
memory as large as an integer, use shmat(2) to get a pointer to
the integer, set the integer value to 0, and test the value
somewhere that's convenient in your code.  When the value is 1,
print out a report, then set the integer value back to 0.   

Then write a simple program that you and your boss can run that
uses the same key for shmget(2), use shmat(2) to get a pointer to
the same integer, and set the integer value to 1.   

			-Jim

-- 
Jim Logan		logan at vsedev.vse.com
(703) 892-0002		uucp:	..!uunet!vsedev!logan
			inet:	logan%vsedev.vse.com at uunet.uu.net



More information about the Comp.unix.questions mailing list