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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:59:30+00:00 2026-06-16T00:59:30+00:00

When i compile the following C++ code with g++ under Linuxit works fine, however

  • 0

When i compile the following C++ code with g++ under Linuxit works fine, however when i try to run

nohup ./a.out &

it stops immediately with info

[7]+  Stopped                 nohup ./a.out

the source code is:

#include <iostream>
#include <fstream>

using namespace std;

int main(void){

    ofstream file("hm.txt",ios::out | ios::binary | ios::app);
    file << "123";
    file.close();

return 0;
}

Can you point out my mistake?

  • 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-16T00:59:31+00:00Added an answer on June 16, 2026 at 12:59 am

    I didn’t get it at first, but it seems like your system is deciding to put the program into a suspended (Stopped state). jobs shows you all of the jobs stopped or running in the current terminal session. bg/fg can be used to restart stopped jobs, so you might check to see if that caused the files to be written. Another idea for further probing the cause is to run /usr/bin/nohup strace ./a.out 1>stdout.txt 2>stderr.txt. The strace should dump all of the system calls to stderr.txt — so you might be able to see an indication as to why it stopped.

    It appears like a common cause for this type of problem is that the program wants some input and since (with nohup) there is no terminal to provide it, the system stops your program. My first suggestion was to try the following in order to provide some auto-generated input:

    /usr/bin/nohup ./a.out </dev/zero
    

    On my system, it automatically runs it with this instead:

    /usr/bin/nohup ./a.out </dev/null
    

    I don’t know why your system wouldn’t automatically be providing a null input, and I also don’t know why your program would be waiting for input. Your original attempt worked fine for me (I can’t reproduce your problem).

    When I run nohup ./a.out (or nohup ./a.out &), I get the following message, which indicates the automatic input suppression:

    nohup: ignoring input and appending output to `nohup.out'
    

    So another line of investigation is: why don’t you see this message?


    Another line of attack, since it seems like your system just doesn’t like nohup with & is to restart the Stopped program as a background task with something like the following:

    /usr/bin/nohup ./a.out & bg
    

    Clearly, nohup is meant to be used with &, so your problem is a bit strange.

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

Sidebar

Related Questions

if I compile (under G++) and run the following code it prints Foo::Foo(int). However
This code fails to compile using g++ 4.2.1 but works fine under vc++ v8.
When I compile the following code, I only see the error during Run-time which
I get Compiler Error C2248 when i try to compile the following code: #include
I'm using nasm to compile the following assembly. However the code crashes in the
I write a parallel code that I can compile it and run it under
I am trying to compile code with the following structure under codeblocks: class a
I'm trying to compile the following code under VC2010. struct CircValRange { double a,b;
Attempting to compile the following code under Qt SDK 4.7.4 for Desktop - MinGW
I have following piece of code: It compiles without problems under gcc-3.4, gcc-4.3, intel

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.