473,320 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Launch/kill process in std C ?

Hello all,
I can launch an external program using system() or the exec() family of
calls. But I'm under the impression that I then can't kill that process
using standard C functions.

kill() is a Linux-only function, right ?
--
Guillaume Dargaud
http://www.gdargaud.net/
Sep 17 '08 #1
5 3505
Guillaume Dargaud said:
Hello all,
I can launch an external program using system() or the exec() family of
calls. But I'm under the impression that I then can't kill that process
using standard C functions.
Right.
kill() is a Linux-only function, right ?
Wrong. It's a POSIX function, and there exist non-Linux POSIX systems.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Sep 17 '08 #2
On Wed, 17 Sep 2008 09:52:12 +0200, Guillaume Dargaud posted:
Hello all,
I can launch an external program using system() or the exec() family of
calls. But I'm under the impression that I then can't kill that process
using standard C functions.

kill() is a Linux-only function, right ?
Just do the memory management in C and let it segfault to kill it.
--
Injustice is relatively easy to bear; what sting is justice.
H. L. Mencken
Sep 17 '08 #3
On Wed, 17 Sep 2008 09:52:12 +0200, Guillaume Dargaud wrote:
I can launch an external program using system() or the exec()
kill() is a Linux-only function, right ?
It's a Unix function and is on unix clones, including Linux; exec is the
same.
Sep 17 '08 #4
>I can launch an external program using system() or the exec() family of
>calls.
exec*() are POSIX calls, not standard C.
>But I'm under the impression that I then can't kill that process
using standard C functions.
It's worse than that. In standard C functions, you aren't guaranteed
to be able to have two processes active at the same time. system()
waits for the process to complete before returning (and whether or
not you can put a process into the background depends on the command
interpreter). If standard C had kill() (which it doesn't), it's
possible nothing will be able to call it until the target process
has finished.
>kill() is a Linux-only function, right ?
It's POSIX, which is a lot more common than Linux.

Sep 17 '08 #5
go***********@burditt.org (Gordon Burditt) writes:
"Guillaume Dargaud"
<us*****************************@www.gdargaud.netw rites:
>>I can launch an external program using system() or the exec() family of
calls.
exec*() are POSIX calls, not standard C.
>>But I'm under the impression that I then can't kill that process
using standard C functions.

It's worse than that. In standard C functions, you aren't guaranteed
to be able to have two processes active at the same time. system()
waits for the process to complete before returning (and whether or
not you can put a process into the background depends on the command
interpreter).
[...]

Not even that much is guaranteed. A conforming implementation could
have system() either wait or not wait for the executed program to
finish.

Here's what the standard says (C99 7.20.4.6):

If string is a null pointer, the system function determines
whether the host environment has a command processor. If string is
not a null pointer, the system function passes the string pointed
to by string to that command processor to be executed in a manner
which the implementation shall document; this might then cause the
program calling system to behave in a non-conforming manner or to
terminate.

If the argument is a null pointer, the system function returns
nonzero only if a command processor is available. If the argument
is not a null pointer, and the system function does return, it
returns an implementation-defined value.

I've restored the attribution line for the quoted material from
Guillaume Dargaud. Permission to quote this article without
attribution is denied.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Sep 17 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Bob Swerdlow | last post by:
My application starts up a number of processes for various purposes using: self.popen = popen2.Popen3("/usr/local/bin/python -O "myscript.py") and then shuts them down when appropriate with...
10
by: Fred | last post by:
There is a setting in INIT.ORA that has the unintended side-effect of making sure the ALTER SYSTEM KILL SESSION command has immediate affect. Without this setting, I've seen some instances where...
7
by: dan glenn | last post by:
I want to use some javascript to launch a windows application (this used on intranet) but don't know how. Can anyone help me out please? It'd be neat if I could not only launch the application...
4
by: Caroline | last post by:
I'd like to launch an executable file from a web page. Basically, the user enters seven parameters and then clicks a button to generate a graph. The input is written to a file and then read by...
3
by: pattanawadee | last post by:
Deall All, Could anybody suggestion me How to kill all inherrit processes (sibling child,previous and parent process) in the case I know only child process id and user id, For example I strart...
0
by: WATYF | last post by:
This is my problem... I have some code that starts a Process and returns it to a variable... (prcBat) At any time while that process is running... I want to be able to Kill it by pressing a...
8
by: Marcus | last post by:
I have this application I have made that I launch when the user logs into Windows XP. I would like to delay the launch of the application so that it starts 1 minute after the user has logged in. ...
4
by: Richard Rossel | last post by:
Hi Fellows, I have a problem with process termination. I have a python code that apache runs through a django interface. The code is very simple, first, it creates a process with the...
7
by: Samuel A. Falvo II | last post by:
I have a shell script script.sh that launches a Java process in the background using the &-operator, like so: #!/bin/bash java ... arguments here ... & In my Python code, I want to invoke...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.