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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:37:34+00:00 2026-05-25T17:37:34+00:00

I am on ubuntu linux 10.04 I have the following #simplec.c #include stdio.h int

  • 0

I am on ubuntu linux 10.04
I have the following

#simplec.c  
#include "stdio.h"

int main()
{

    printf("Hello World\n");
    system("ps -H");
    return 12;


}

AND

#callsimplec.c
#include "stdio.h"

int main()
{

    int ret =0;
    ret = system("./simplec");
    printf("In callsimplec ret is %d\n", ret);

}

When I do

gcc callsimplec.c -o callsimplec
gcc simplec.c -o simplec
./callsimplec

I get:

Hello World
  PID TTY          TIME CMD
27238 pts/2    00:00:00 bash
28066 pts/2    00:00:00   callsimplec
28067 pts/2    00:00:00     simplec
28068 pts/2    00:00:00       ps
In callsimplec ret is 3072

So I figured out that 3072 is printed because 256 times 12 is 3072. Whatever return value I use in simplec.c I get that value multiplied by 256 as the output in print. Why is that? I am just trying to make sense of it.

  • 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-25T17:37:35+00:00Added an answer on May 25, 2026 at 5:37 pm

    The value returned by system should be used with the macros: WEXITED, WIFEXITSTATUS etc.

    The value returned by system (and by the wait family) is, acording to case:

    • Normal termination:

      15 ............. 8 ............. 0
          exit status         0x00
      
    • Killed by signal:

      15 ............. 8 7............ 0
            unused        killer signal
      
    • Stopped by signal

      15 ............. 8 ............. 0
          stop signal         0x7f
      
    • Continued by signal

      15 ............................. 0
                     0xFFF
      

    So in your case the process exited normally and system returned 12 shifted 8 times.

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

Sidebar

Related Questions

I have a following problem: I compiled my application on Linux Ubuntu 9.10 using
I have this following simple program: int main() { char* v = getenv(TEST_VAR); cout
I have the following constellation here: I have running a VMware Linux Ubuntu image
I have following this blog in setting Xvfb in my ubuntu environment: http://corpocrat.com/2008/08/19/how-to-install-xvfb-x11-server-in-linux-server/ So
I have Ubuntu Linux. I found one command will let me download unread message
I have a server that is running Ubuntu Linux Server Edition. I once had
I have configured my Django app to run under Apache+FastCGI on Linux (Ubuntu, if
I have a (from what I can tell) perfectly working Linux setup (Ubuntu 8.04)
All, I have installed xampp for linux on ubuntu 9.10. The installation directory is
I have a Windows XP machine and a Linux machine running Ubuntu. I share

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.