Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6693581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:59:59+00:00 2026-05-26T05:59:59+00:00

I have an NSTask that’s executing another program I wrote. In that command line

  • 0

I have an NSTask that’s executing another program I wrote. In that command line program, it expects the ETX (control-C, or ASCII value 3) to pause one of its processes and call another function. How can I send this? I know I’m sending commands correctly because the program interacts with every command I’ve sent it so far except ETX. I’m using the following code but it does not work:

NSString *cmdScan = [NSString stringWithFormat:@"%c", 3];
[inputHandle writeData: [cmdScan dataUsingEncoding:NSUTF8StringEncoding]];
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T05:59:59+00:00Added an answer on May 26, 2026 at 5:59 am

    (I’m assuming you want to emulate the behavior of the ctrl+c keystroke in a terminal window. If you really mean to send an ETX to the target process, this answer isn’t going to help you.)

    The ctrl+c keyboard combination doesn’t send an ETX to the standard input of the program. This can easily be verified as regular keyboard input can be ignored by a running program, but ctrl+c (usually) immediately takes effect. For instance, even programs that completely ignore the standard input (such as int main() { while (1); }) can be stopped by pressing ctrl+c.

    This works because terminals catch the ctrl+c key combination and deliver a SIGINT signal to the process instead. Therefore, writing an ETX to the standard input of a program has no effect, because the keystroke is caught by the terminal and the resulting character isn’t delivered to the running program’s standard input.

    You can send SIGINT signals to processes represented by a NSTask by using the -[NSTask interrupt] method.

    [task interrupt];
    

    Otherwise, you can also send arbitrary signals to processes by using the kill function (which, mind you, doesn’t necessarily kills programs).

    #include <signal.h>
    kill(task.processIdentifier, SIGINT);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that checks its command line parameters and stores values in
I have created a simple command line tool that outputs hello world. This is
I have an NSTextView that I'm outputting text from NSTask. Everything works as expected
I have an application that can import an XML file through this terminal command
I have a app that calls an NSTask, (I have written the NSTask and
I have some code that is attached to an NSTimer. Around 5 times every
I need to have a progress bar that responds to the percent complete of
I am working on a GUI (Cocoa) for a command-line tool to make it
I have created a Mac OS X helper application that always runs under root.
Hi I have the following code: - (IBAction)runTask:(id)sender { NSTask *proc; NSPipe *output; NSData

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.