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

  • Home
  • SEARCH
  • 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 3457796
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:54:15+00:00 2026-05-18T09:54:15+00:00

I am working on a relatively simple, independent process starter that I would like

  • 0

I am working on a relatively simple, independent “process starter” that I would like to get to work on Windows (XP, Vista, 7), Linux (Ubuntu 10.10) and especially Mac OS X (10.6). Linux and Windows basically work, but I’m having some trouble with the Mac version.
I was hoping fork() and exec() functions would work the same way under Mac OS as they work in Linux. So my first question is:

  1. Should I use these to create a
    process on the Mac or are there any
    platform specific functions to be
    used?

My current code (which worked fine under Linux) to debug this looks something like this:

pid_t processId = 0;
if (processId = fork()) == 0)
{
    const char * tmpApplication = "/Path/to/TestApplication";

    int argc = 1;
    char * argv[argc + 1];

    argv[0] = tmpApplication;
    argv[1] = NULL;

    execv(tmpApplication, argv);
}else
{
    //[...]
}

Any idea if this could work under Mac OS X as well, because my child process is simply not being launched, while there are no errors that would come up.

Thank you!

  • 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-18T09:54:16+00:00Added an answer on May 18, 2026 at 9:54 am

    The following program, adapted from your code, works just fine for me under OS X:

    #include <stdio.h>
    #include <stdlib.h>
    #include <unistd.h>
    #include <sys/types.h>
    
    int main (void) {
        pid_t processId;
        if ((processId = fork()) == 0) {
            char app[] = "/bin/echo";
            char * const argv[] = { app, "success", NULL };
            if (execv(app, argv) < 0) {
                perror("execv error");
            }
        } else if (processId < 0) {
            perror("fork error");
        } else {
            return EXIT_SUCCESS;
        }
        return EXIT_FAILURE;
    }
    

    I suggest you start with this simple fragment, and if it works keep adding things until you find what makes it break.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a relatively simple site that I'm working up for an intranet environment.
I'm working on a relatively simple iPhone application that has a multi-round Timer with
The Project I'm working on a relatively simple iPhone OS project that's navigation controller
I am working on a relatively simple program in VB.NET. I am trying to
I'm working on a relatively simple website with (currently) a single resource. I have
I'm working on a relatively simple 2D side-scrolling iPhone game. The controls are tilt-based.
I'm working on a website with simple jquery effects, like show, hide... http://emilione.altervista.org/works.html This
I'm working on a relatively small asp.net web application and am wondering if there
Working with dates in ruby and rails on windows, I'm having problems with pre-epoch
Working with a SqlCommand in C# I've created a query that contains a IN

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.