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 1898014
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:42:54+00:00 2026-05-17T06:42:54+00:00

#include <stdio.h> #include <unistd.h> #include <stdlib.h> int main (int argc, const char * argv[])

  • 0
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

int main (int argc, const char * argv[])
{
    printf("start\n");
    char *const parmList[] = {"/bin/ls", "-l", NULL};
    execv("/bin/ls", parmList);
    return 0;
}

I compiled with GCC4.2 Any ideas why this might crash? I’m not getting any error messages in xcode.

EDIT: user error. “crash” meant xcode froze when it ran the program. Pressing continue works fine.

  • 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-17T06:42:55+00:00Added an answer on May 17, 2026 at 6:42 am

    That code runs and compiles fine in my environment, gcc 4.4.3 under Ubuntu 10. That leads me to believe that you have a different problem from the one you think you have 🙂


    pax@pax-desktop:~$ ./testprog
    start
    total 2152
    drwxr-xr-x 11 pax pax    4096 2010-10-02 08:23 Pax
    : :
    ----r-S---  1 pax pax       0 2010-08-23 18:58 xyz
    
    pax@pax-desktop:~$ gcc --version
    gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3
    Copyright (C) 2009 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    

    Try the following code to see if the actual exec is failing. If it is, it should tell you why. If it isn’t, then you won’t see the rc output at all.

    #include <stdio.h>
    #include <unistd.h>
    #include <stdlib.h>
    #include <errno.h>
    
    int main (int argc, const char * argv[])
    {
        int rc;
        printf("start\n");
        char *const parmList[] = {"/bin/ls", "-l", NULL};
        rc = execv("/bin/ls", parmList);
        printf ("rc = %d, errno = %d\n", rc, errno);
        return 0;
    }
    

    Also check to make sure the /bin/ls is what you expect it to be (an executable, not a script, for example).

    And it’s worth clarifying what you mean by “crash”. Is it just not producing any output? It it dumping a core file? Is it bringing your entire OS to its knees, causing a reboot?

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

Sidebar

Related Questions

#include<stdio.h> #include<zlib.h> #include<unistd.h> #include<string.h> int main(int argc, char *argv[]) { char *path=NULL; size_t size;
#include<stdio.h> #include<unistd.h> #include<stdlib.h> int main(int argc,char **argv) { int fd[2]; pid_t childpid; pipe(fd); childpid=fork();
#include <stdlib.h> #include <unistd.h> #include <string.h> #include <sys/types.h> #include <stdio.h> int main(int argc, char
Here is my code: #include<stdio.h> #include<stdlib.h> #include<sys/stat.h> #include<sys/types.h> #include<fcntl.h> #include<unistd.h> #include<errno.h> int main(int argc,char
In this C program #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> int main()
I wrote a simple C program: #include <unistd.h> #include <stdio.h> int main( int argc,
Consider the following piece of code: #include <stdio.h> #include <sys/types.h> #include <unistd.h> int main(void)
This is my code: #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <pthread.h> int num_mezzo_1(int
This is my chat server : #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h>
Client code: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h>

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.