<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Killing process using C in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/killing-process-using-c/m-p/3583166#M103763</link>
    <description>I'm positive that since you are already using C is to the easist way is&lt;BR /&gt;cc = kill(pid,0);&lt;BR /&gt;if (cc == 0)&lt;BR /&gt;  {&lt;BR /&gt;    /* valid process */&lt;BR /&gt;  }&lt;BR /&gt;else&lt;BR /&gt;  {&lt;BR /&gt;    /* invalid process */&lt;BR /&gt;  }&lt;BR /&gt;</description>
    <pubDate>Wed, 20 Jul 2005 10:39:03 GMT</pubDate>
    <dc:creator>A. Clay Stephenson</dc:creator>
    <dc:date>2005-07-20T10:39:03Z</dc:date>
    <item>
      <title>Killing process using C</title>
      <link>https://community.hpe.com/t5/operating-system-linux/killing-process-using-c/m-p/3583161#M103758</link>
      <description>Hi Guys,&lt;BR /&gt;&lt;BR /&gt;  I would like to kill a process using C, I know the PID so I use:&lt;BR /&gt;&lt;BR /&gt;kill(PID, SIGTSP); &lt;BR /&gt;&lt;BR /&gt;But is it possible to see if this  process is valid using C as well? What is the common practise?&lt;BR /&gt;&lt;BR /&gt;Thank u.&lt;BR /&gt;Henry</description>
      <pubDate>Thu, 14 Jul 2005 20:59:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/killing-process-using-c/m-p/3583161#M103758</guid>
      <dc:creator>Henry Chua</dc:creator>
      <dc:date>2005-07-14T20:59:32Z</dc:date>
    </item>
    <item>
      <title>Re: Killing process using C</title>
      <link>https://community.hpe.com/t5/operating-system-linux/killing-process-using-c/m-p/3583162#M103759</link>
      <description>Hi Henry,&lt;BR /&gt;&lt;BR /&gt;By you asking &lt;BR /&gt;But is it possible to see if this process is valid using C as well?&lt;BR /&gt;Do you mean about the PID? you want to check if its a valid PID? You can do that using the raise() function which actally is used to send signal to a running process and looking at the man pages you see&lt;BR /&gt;"If sig is 0 (the null signal), error checking is performed but no&lt;BR /&gt;      signal is actually sent.  This can be used to check the validity of&lt;BR /&gt;      pid." So before you use the kill function you can call the raise function.&lt;BR /&gt;&lt;BR /&gt;Also why do you want to re-invent a wheel until its a real requirement in your program or a module you are trying to add.&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;Rajeev&lt;BR /&gt;</description>
      <pubDate>Thu, 14 Jul 2005 22:02:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/killing-process-using-c/m-p/3583162#M103759</guid>
      <dc:creator>Rajeev  Shukla</dc:creator>
      <dc:date>2005-07-14T22:02:01Z</dc:date>
    </item>
    <item>
      <title>Re: Killing process using C</title>
      <link>https://community.hpe.com/t5/operating-system-linux/killing-process-using-c/m-p/3583163#M103760</link>
      <description>Hi Rajeev, &lt;BR /&gt;&lt;BR /&gt;  Thanks for the info, raise() sends signal to itself to its validity, however is there any way i can test process running in the background. &lt;BR /&gt;  Say i ps -ef and know process A with PID 9081 is running. But after say an hour i want to see if it is still residing in the spool. Is there anyway I can write a procedure in C to test whether this PID is still active... even better if I can see the actual program using this PID...&lt;BR /&gt;&lt;BR /&gt;Best regards&lt;BR /&gt;Henry</description>
      <pubDate>Thu, 14 Jul 2005 22:46:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/killing-process-using-c/m-p/3583163#M103760</guid>
      <dc:creator>Henry Chua</dc:creator>
      <dc:date>2005-07-14T22:46:10Z</dc:date>
    </item>
    <item>
      <title>Re: Killing process using C</title>
      <link>https://community.hpe.com/t5/operating-system-linux/killing-process-using-c/m-p/3583164#M103761</link>
      <description>I'm not C conversant,&lt;BR /&gt;so probably not entitled to advise you.&lt;BR /&gt;But the common practise (that I also use in Perl scrcipts) is to send the PID as signal 0.&lt;BR /&gt;See also "man 2 kill" where they mention the action on receipt of 0.</description>
      <pubDate>Fri, 15 Jul 2005 00:00:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/killing-process-using-c/m-p/3583164#M103761</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2005-07-15T00:00:02Z</dc:date>
    </item>
    <item>
      <title>Re: Killing process using C</title>
      <link>https://community.hpe.com/t5/operating-system-linux/killing-process-using-c/m-p/3583165#M103762</link>
      <description>I'm pretty sure the easiest way is to send a system command.&lt;BR /&gt;your system command can either call a script or send the command&lt;BR /&gt;ps -ef | grep pid | kill -9 `awk '{print $2}'`</description>
      <pubDate>Wed, 20 Jul 2005 10:32:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/killing-process-using-c/m-p/3583165#M103762</guid>
      <dc:creator>Renda Skandier</dc:creator>
      <dc:date>2005-07-20T10:32:12Z</dc:date>
    </item>
    <item>
      <title>Re: Killing process using C</title>
      <link>https://community.hpe.com/t5/operating-system-linux/killing-process-using-c/m-p/3583166#M103763</link>
      <description>I'm positive that since you are already using C is to the easist way is&lt;BR /&gt;cc = kill(pid,0);&lt;BR /&gt;if (cc == 0)&lt;BR /&gt;  {&lt;BR /&gt;    /* valid process */&lt;BR /&gt;  }&lt;BR /&gt;else&lt;BR /&gt;  {&lt;BR /&gt;    /* invalid process */&lt;BR /&gt;  }&lt;BR /&gt;</description>
      <pubDate>Wed, 20 Jul 2005 10:39:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/killing-process-using-c/m-p/3583166#M103763</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-07-20T10:39:03Z</dc:date>
    </item>
  </channel>
</rss>

