By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,433 Members | 1,649 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,433 IT Pros & Developers. It's quick & easy.

Syscall problem ?

P: n/a
Hi :

I code a program by c called "inter". I have another program called
"end"

Can I code in "end " to use the syscall ( "inter") ?

If Yes , which kind of command format should I write?

thanks for any comments.

bin

Nov 15 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
In article <11**********************@g43g2000cwa.googlegroups .com>,
yezi <ye*****@hotmail.com> wrote:
I code a program by c called "inter". I have another program called
"end" Can I code in "end " to use the syscall ( "inter") ? If Yes , which kind of command format should I write?


I suggest you examine the documentation for the system() routine.
Pretty much all the standard says is that this will invoke
system-defined behaviour. -Usually- the string you pass into
system() is a command line that will be parsed by -something-
and the appropriate program started up.

Note: if "inter" really is a "syscall" (system call) then the
mechanisms you will need to invoke it would be operating system
dependant. Most operating systems make it difficult to add
your own system calls.
--
I am spammed, therefore I am.
Nov 15 '05 #2

P: n/a
I have another problem with that. Suppose I systemcall the function is
success, is that mean "inter" and the "end " is running simultaneously
or like the following way :

"end" ->"inter" then "end".

Thanks

Nov 15 '05 #3

P: n/a
In article <11*********************@g43g2000cwa.googlegroups. com>,
yezi <ye*****@hotmail.com> wrote:
I have another problem with that. Suppose I systemcall the function is
success, is that mean "inter" and the "end " is running simultaneously
or like the following way : "end" ->"inter" then "end".


Here is the entire C89 documentation about system()

=== begin documentation ===
4.10.4.5 The system Function

Synopsis:
#include <stdlib.h>
int system(const char *string);

Description:

The system function passes the string pointed to by string to
the host environment to be executed by a command processor in an
implementation-defined manner. A null pointer may be used for
string to inquire whether a command processor exists.

Returns:

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, the system function returns an implementation-defined
value.
=== end documentation ===

Looking at this, you can see that what happens is operating-system
specific, not defined by C. In order to know what happens on *your*
operating system, you should consult the documentation for your
operating system, or ask in a newsgroup specific to that operating
system.
The most -common- behaviour is that system() does not return
until the invoked command terminates, but that is not the only
behaviour possible and on many systems the behaviour can be modified
in an operating-system specific manner.

If you are trying to get the called program to execute at the same time
as the calling program, the mechanisms for doing that are operating
system specific, and you should consult elsewhere. In particular,
the mechanisms for Windows are considerably different than those
for Unix-like systems.
--
If you lie to the compiler, it will get its revenge. -- Eric Sosman
Nov 15 '05 #4

P: n/a
On 2005-10-31, Walter Roberson <ro******@ibd.nrc-cnrc.gc.ca> wrote:
In article <11*********************@g43g2000cwa.googlegroups. com>,
yezi <ye*****@hotmail.com> wrote:
I have another problem with that. Suppose I systemcall the function is
success, is that mean "inter" and the "end " is running simultaneously
or like the following way :

"end" ->"inter" then "end".


Here is the entire C89 documentation about system()

=== begin documentation ===
4.10.4.5 The system Function

Synopsis:
#include <stdlib.h>
int system(const char *string);

Description:

The system function passes the string pointed to by string to
the host environment to be executed by a command processor in an
implementation-defined manner. A null pointer may be used for
string to inquire whether a command processor exists.

Returns:

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, the system function returns an implementation-defined
value.
=== end documentation ===


C99 adds:
| 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

This tells me that reasonable things for an implementation to do
are:

Block until the command finishes.

Return immediately, and then the command and your program run
concurrently.

Replace your program with the requested command.
hmm - this is really another subject, but on the same page as that:

The implementation shall behave as if no library function calls the
getenv function.

that strikes me as odd. many implementations have lots of library
functions that use environment variables, particularly for
locale-dependent stuff, or for determining the local timezone. Or
are they allowed to look in the environment as long as they don't do
it by calling getenv?
Nov 15 '05 #5

P: n/a
On Tue, 01 Nov 2005 03:05:16 +0000, Jordan Abel wrote:
[...]
hmm - this is really another subject, but on the same page as that:

The implementation shall behave as if no library function calls the
getenv function.

that strikes me as odd. many implementations have lots of library
functions that use environment variables, particularly for
locale-dependent stuff, or for determining the local timezone. Or
are they allowed to look in the environment as long as they don't do
it by calling getenv?


They're even allowed to do it by calling getenv, so long as they behave as
though they're not.

--
http://members.dodo.com.au/~netocrat
Nov 15 '05 #6

P: n/a
In article <sl*******************@random.yi.org>,
Jordan Abel <jm****@purdue.edu> wrote:
On 2005-10-31, Walter Roberson <ro******@ibd.nrc-cnrc.gc.ca> wrote:
Here is the entire C89 documentation about system()

C99 adds:
| 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 This tells me that reasonable things for an implementation to do
are: Block until the command finishes. Return immediately, and then the command and your program run
concurrently. Replace your program with the requested command.


You missed some cases, such as system() of something that
sends a fatal signal to your program; or system() of something that
messes with your own process memory; or system() of something that
messes with kernel memory; or system() of something that crashes
taking down the system with it.
--
Programming is what happens while you're busy making other plans.
Nov 15 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.