The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to start a process and make it sleep for 5 mins and then kill that process shrao Shell Programming and Scripting 6 03-27-2007 12:54 PM
Process KILL rkrgarlapati Shell Programming and Scripting 2 09-22-2006 05:07 AM
When kill doesnt work, how to kill a process ? VijayHegde UNIX for Advanced & Expert Users 3 05-12-2006 04:24 PM
HP UX How to kill Process prakashpichika HP-UX 5 02-10-2006 01:40 AM
who -uH, kill the process at different pts/tb yls177 UNIX for Dummies Questions & Answers 3 12-11-2002 09:32 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-19-2007
umen umen is offline
Registered User
  
 

Join Date: Aug 2005
Posts: 239
kill(0,-9) don't kill the process

Hi all
i have simple c program , when i wish to kill the app
im using kill(0,-9) , but it seams this command don't do any thing and the program.
just ignore it .
what im doing wrong here ?
im using HP-UX ia64

Thanks
  #2 (permalink)  
Old 06-19-2007
ilko_partizan's Avatar
ilko_partizan ilko_partizan is offline
Registered User
  
 

Join Date: Apr 2007
Location: EU, Bulgaria
Posts: 33
You can kill a program with command:
kill -9 <PID of programme>
If you can not necessary permission about programme, You won't kill a programme.

Best regards,
Iliyan Varshilov

Last edited by ilko_partizan; 06-19-2007 at 03:45 AM..
  #3 (permalink)  
Old 06-19-2007
umen umen is offline
Registered User
  
 

Join Date: Aug 2005
Posts: 239
i need to kill from c program
  #4 (permalink)  
Old 06-19-2007
ilko_partizan's Avatar
ilko_partizan ilko_partizan is offline
Registered User
  
 

Join Date: Apr 2007
Location: EU, Bulgaria
Posts: 33
If you need killing a process from C programme, You will read about system call 'kill'.

http://www.freebsd.org/cgi/man.cgi?q...SE&format=html

Best regards,
Iliyan Varshilov

Last edited by ilko_partizan; 06-19-2007 at 04:42 AM..
  #5 (permalink)  
Old 06-19-2007
umen umen is offline
Registered User
  
 

Join Date: Aug 2005
Posts: 239
hi
i have read it also read this :
http://www.cs.cf.ac.uk/Dave/C/node24...00000000000000
that helped me understand this is my code:

Code:
int k=kill(getpid(),-9);
int r=raise(-9);
the return codes from k and r is -1
that is it proform the kill command but failled , the question is why ?
the getpid() also returns the right pid .
so what can i do next ?
how can i catch errno msg?
what else i can do to understand what is wrong ?

thanks
  #6 (permalink)  
Old 06-19-2007
ilko_partizan's Avatar
ilko_partizan ilko_partizan is offline
Registered User
  
 

Join Date: Apr 2007
Location: EU, Bulgaria
Posts: 33
You can get a error in string format from your programme with function 'strerror'.
This is part of code you needed:

Code:
#include <errno.h>
#include <stdio.h>

fprintf(stderr, "Error: %s\n", strerror(errno));
This man page describes 'errno'.
http://www.freebsd.org/cgi/man.cgi?q...SE&format=html

This man page describes 'strerror'.
http://www.freebsd.org/cgi/man.cgi?q...SE&format=html

Best regards,
Iliyan Varshilov

Last edited by ilko_partizan; 06-19-2007 at 04:07 AM..
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:27 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0