Here is most of the code minus the logic specific to my case. It may not be the cleanest way, but it works for me. I have more includes then are needed but that is for other stuff I am doing in the same binary. chmod 4555 with this does what I wanted. code tags added for readability -- Perderabo
Last edited by Perderabo; 07-16-2003 at 12:41 PM..
i have a very short file that has in it a line for a find command.
now, when i run this script and I kill the script later, using the ps -ef | grep scriptname. i noticed kill -9 kills the script itself but does not kill the internal find command that it gave birth to.
say theres a file... (0 Replies)
Hi guys,
I am new to Unix shell scripting. Can anyone of you tell me how to kill all the processes at a time for a particular user?(No listing the process ID of each process in the kill -9 command).
Thanks in Advance,
-Hary (5 Replies)
how to kill the processes of aperticular user?
because i have nearly 25000 process are there for perticular user. i need to kill.
Please provide the information?
Regards,
Rajesh (3 Replies)
Hi,
How to kill the processes running under ptree ?
I am noticing lot of processes running under ptree with ssh ? I tried to kill with -9 option which is not working ?
Thanks,
Radhika. (2 Replies)
Hi,
I am writing korn shell script. My requirement is, i have to kill the parent process and all of its child processes. Can some one please help me on this?
Thanks in advance for your help.. (1 Reply)
for i in 'ps -f | grep textedit'
do
kill $i
done
I wrote this but it wont work.
I am trying to find processes and kill them.
Any help would be welcome. (1 Reply)
Hi there, i've been searching all over and i thought i had understood the way i should go to kill all the processes related to a user. But i'm getting more confused then i was.
By lunch time i have to make a database backup, and for that all the users shoul logout. The problem is that many users... (4 Replies)
Want to kill multiple processes by name. for the example below, I want to kill all 'proxy-stagerd_copy' processes.
I tried this but didn't work:
>> ps -ef|grep proxy_copy
root 991 986 0 14:45:34 ? 0:04 proxy-stagerd
root 1003 991 0 14:45:49 ? 0:01... (2 Replies)
Hi all,
I have about 5-6 daemons specific to my application running in the background. I am trying to write a script to stop them. Usually, I run them as a non-root ID, which is fine. But for some reason the client insists on using root.
I do have sudo.
I just tried something like this
... (4 Replies)
Discussion started by: jeffs42885
4 Replies
LEARN ABOUT OPENSOLARIS
p2close
p2open(3GEN) String Pattern-Matching Library Functions p2open(3GEN)NAME
p2open, p2close - open, close pipes to and from a command
SYNOPSIS
cc [ flag ... ] file ... -lgen [ library ... ]
#include <libgen.h>
int p2open(const char *cmd, FILE *fp[2]);
int p2close(FILE *fp[2]);
DESCRIPTION
The p2open()gfunction forks and execs a shell running the command line pointed to by cmd. On return, fp[0] points to a FILE pointer to
write the command's standard input and fp[1] points to a FILE pointer to read from the command's standard output. In this way the program
has control over the input and output of the command.
The function returns 0 if successful; otherwise, it returns -1.
The p2close() function is used to close the file pointers that p2open() opened. It waits for the process to terminate and returns the
process status. It returns 0 if successful; otherwise, it returns -1.
RETURN VALUES
A common problem is having too few file descriptors. The p2close() function returns -1 if the two file pointers are not from the same
p2open().
EXAMPLES
Example 1 Example of file descriptors.
#include <stdio.h>
#include <libgen.h>
main(argc,argv)
int argc;
char **argv;
{
FILE *fp[2];
pid_t pid;
char buf[16];
pid=p2open("/usr/bin/cat", fp);
if ( pid == -1 ) {
fprintf(stderr, "p2open failed
");
exit(1);
}
write(fileno(fp[0]),"This is a test
", 16);
if(read(fileno(fp[1]), buf, 16) <=0)
fprintf(stderr, "p2open failed
");
else
write(1, buf, 16);
(void)p2close(fp);
}
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|MT-Level |Unsafe |
+-----------------------------+-----------------------------+
SEE ALSO fclose(3C), popen(3C), setbuf(3C), attributes(5)NOTES
Buffered writes on fp[0] can make it appear that the command is not listening. Judiciously placed fflush() calls or unbuffering fp[0] can
be a big help; see fclose(3C).
Many commands use buffered output when connected to a pipe. That, too, can make it appear as if things are not working.
Usage is not the same as for popen(), although it is closely related.
SunOS 5.11 29 Dec 1996 p2open(3GEN)