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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:05:12+00:00 2026-06-12T03:05:12+00:00

I am learning linux programming and came across exec function which is kind of

  • 0

I am learning linux programming and came across exec function which is kind of very useful. But the problem is exec function arguments are very confusing and I am unable to grasp which argument is for what purpose.. In the following code execl() function is called from a child created through fork(), What is the purpose of the last argument (NULL) in execl()?

execl("/bin/ls","ls","-l",NULL);

If any one can explain what is the purpose of NULL argument and other arguments and the purpose of arguments of exec() family function, It would be a great help to me!

  • 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-06-12T03:05:13+00:00Added an answer on June 12, 2026 at 3:05 am

    To create undefined behavior. That is not a legal call to execl. A
    correct call might be:

    execl( "/bin/ls", "ls", "-l", (char*)0 );
    

    The last argument must be (char*)0, or you have undefined behavior.
    The first argument is the path of the executable. The following
    arguments appear in argv of the executed program. The list of these
    arguments is terminated by a (char*)0; that’s how the called function
    knows that the last argument has been reached. In the above example,
    for example, the executable at "/bin/ls" will replace your code; in
    its main, it will have argc equal 2, with argv[0] equal "ls",
    and argv[1] equal "-l".

    Immediately after this function, you should have the error handling
    code. (execl always returns -1, when it returns, so you don’t need to
    test it. And it only returns if there was some sort of error.)

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

Sidebar

Related Questions

I'm learning the C language on Linux now and I've came across a little
OS: Linux, Language: pure C I'm moving forward in learning C programming in general,
I learning Objective-C in Linux(Ubuntu), but when i tryed to compile my application that
I am learning socket programming under Linux,so I make a sample program to list
I am learning linux programming and want to do the following. I would like
I just began learning network programming. My first program is very simple: once connected,
I am learning Linux module programming. I work on Ubuntu 12.04. I made a
I was learning linux system programming, O'reilly. It says A common mistake is to
Which distro to use for learning linux(from job perspective). Which distro is used by
I am learning c programming in Linux. There are a lot of linux functions

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.