Find the answer to your Linux question:
Results 1 to 10 of 10
Hi again, I was just wondering if anyone knew how to figure out why a c++ program I wrote si terminated prematurely without any seg faults or anything else by ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jul 2004
    Location
    Seattle, WA or Lewisburg, PA. Depending on time of year.
    Posts
    37

    how to find out why linux terminates program?


    Hi again,

    I was just wondering if anyone knew how to figure out why a c++ program I wrote si terminated prematurely without any seg faults or anything else by linux (i think its a knoppix distro that's runnign on the machines I'm using) I just dont'' understand why it would terminate my program, since I can't seem to find any problem in my code...

    thanks

  2. #2
    Linux User zba78's Avatar
    Join Date
    Feb 2004
    Location
    Birmingham, England
    Posts
    335
    Sorry but if there are no error messages and we do not know what code it is that you are trying to run it is virtually impossible for us to help you.
    Ubuntu Jaunty :: Arch Linux (current) :: Acer Aspire 1692WMLi

  3. #3
    Linux Engineer
    Join Date
    Jul 2003
    Location
    Stockholm, Sweden
    Posts
    1,296
    exactly.. maby some magic dust fell on your computer or something :) please post the code you are having problems with also what disto/kernel version/compiler version and any compile options you used to compile it.

  4. #4
    Linux User
    Join Date
    Jul 2004
    Posts
    256
    Make sure you run it from a term, so you can see stderr and stdout.
    --monkey

  5. #5
    Linux Guru kkubasik's Avatar
    Join Date
    Mar 2004
    Location
    Lat: 39:03:51N Lon: 77:14:37W
    Posts
    2,396
    have you tried compiling w/o any optimizer flags?
    Avoid the Gates of Hell. Use Linux
    A Penny for your Thoughts

    Formerly Known as qub333

  6. #6
    Linux Engineer
    Join Date
    May 2003
    Location
    Greece / Athens
    Posts
    1,169
    if you run it in console mode use redirection of stderr(2) to a file with &2> filename
    Linux For Ever!

  7. #7
    Just Joined!
    Join Date
    Jul 2004
    Location
    Seattle, WA or Lewisburg, PA. Depending on time of year.
    Posts
    37
    Hey, sorry i wasn't very desscriptive, but I really can't be, especially with posting the code. I was just trying to see if there waas a general method for such things, not for a particular solution. Please don't misunderstand though, I really do appreciate all the replies!

    Stahisx, do you mean
    Code:
    program-name &2 > "outputfileneme"
    ? IN the mean time, what is stderr(2), that sounds like a stupid question I know. I've used stderr a bunch, but what is stderr(2)?

    Actually, this might help... can redhat (i don't know what version) terminate a program if that program will use all available ram and over? like a program-destruct? This occured to me while i was trying to fix things today...

    thanks again!

  8. #8
    Just Joined!
    Join Date
    Jul 2004
    Location
    Berea College
    Posts
    22
    Yes, if a program starts using too much memory the kernel will kill the program. It does this to help prevent memory overflows (which can corrupt your kelnel)

  9. #9
    Linux Engineer
    Join Date
    May 2003
    Location
    Greece / Athens
    Posts
    1,169
    stderr holds all the errors occur when something goes wrong.so with this code you redirect errors in a file.you can also use /var/log/messages to see error logs...
    Linux For Ever!

  10. #10
    Just Joined!
    Join Date
    Jun 2004
    Posts
    11
    this may not matter much and im no guru, but i use knoppix and its an unstable kernel version if that matters..... just a thought and hope it helps =)


    daemox

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •