• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: call C application
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: call C application


  • Subject: Re: call C application
  • From: "email@hidden" <email@hidden>
  • Date: Fri, 28 Apr 2006 00:45:51 +0400

Mai Bui wrote:
Can a cocoa application call another application written in C?

For instance, I have a cocoa application with the "RUN" and "STOP" button.
I would like to implement:
- when the user press "RUN" button, it will run another my application (written in C).
- and press "STOP" button, it send 'q' character to the running application to stop that application and then quit its self (the cocoa application).


Is it possible to do that?

Thanks for any idea and help.
Way 1 (Cocoa way):

Please read documentation for NSTask class. Use NSTask as wrapper.
http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSTask.html

Way 2 (UNIX way):

If you don't want to hook input/output streams (STDIN/STDOUT) then you can simple call C-library function
system();


from man:

NAME
    system -- pass a command to the shell

LIBRARY
    Standard C Library (libc, -lc)

SYNOPSIS
    #include <stdlib.h>

    int
    system(const char *string);

DESCRIPTION
The system() function hands the argument string to the command inter-
preter sh(1). The calling process waits for the shell to finish execut-
ing the command, ignoring SIGINT and SIGQUIT, and blocking SIGCHLD.


If string is a NULL pointer, system() will return non-zero if the command
interpreter sh(1) is available, and zero if it is not.


The system() function returns the exit status of the shell as returned by
waitpid(2), or -1 if an error occurred when invoking fork(2) or
waitpid(2). A return value of 127 means the execution of the shell




_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: call C application
      • From: Ondra Cada <email@hidden>
    • Re: call C application
      • From: Nick Zitzmann <email@hidden>
References: 
 >call C application (From: Mai Bui <email@hidden>)

  • Prev by Date: Drag drop - namesOfPromisedFilesDroppedAtDestination has an indexSet = nil
  • Next by Date: Re: Drag drop - namesOfPromisedFilesDroppedAtDestination has an indexSet = nil
  • Previous by thread: Re: call C application
  • Next by thread: Re: call C application
  • Index(es):
    • Date
    • Thread