473,382 Members | 1,329 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

When will exit(0) fail to exit?

My program is about several thousands lines. It takes arguements from
the command line.
If no arguement is given, it should simply exist. Below is the
architectureof main() :

int main(int argc, char *argv[])
{
if( argc == 1 )
{
cout << "NO ARGUEMENT"<<endl;
exit(0);
}
//Other parts of the code

return 0; //LastLine

}
It also links with other libraries.
If no arguement is given on command line, it only outputs "NO
ARGUEMENT", then hangs there.
The exit(0) can not exit. Why exit(0) fails to exit from main()?

If I give correct arguements at command line, the program also hangs.
The return 0 at the LastLine can not exit, either.

The code links some C++ libraries. It only hangs on AIX systems. But
for Linux, it works fine. Why?

I find that maybe a C++ library causes the problem. What should I do?
I have to link that library. Otherwise, the linker complains
"Undefined symbols", although some symbols are not needed in my code,
but they are used in other libraries.
Thanks.
Jan 21 '08 #1
5 5320
ju******@gmail.com wrote:
My program is about several thousands lines. It takes arguements from
the command line.
If no arguement is given, it should simply exist. Below is the
architectureof main() :
#include <cstdlib>

int main(int argc, char *argv[])
{
using namespace std;
>
if( argc == 1 )
{
cout << "NO ARGUEMENT"<<endl;
exit(0);
}
//Other parts of the code

return 0; //LastLine

}
It also links with other libraries.
If no arguement is given on command line, it only outputs "NO
ARGUEMENT", then hangs there.
The exit(0) can not exit. Why exit(0) fails to exit from main()?

If I give correct arguements at command line, the program also hangs.
The return 0 at the LastLine can not exit, either.

The code links some C++ libraries. It only hangs on AIX systems. But
for Linux, it works fine. Why?

I find that maybe a C++ library causes the problem. What should I do?
I have to link that library. Otherwise, the linker complains
"Undefined symbols", although some symbols are not needed in my code,
but they are used in other libraries.

Supposing you included <cstdlibas I did above, it sounds like a bug of
your compiler. However you do not need to call exit(). A simple "return
0;" statement would suffice.
Jan 21 '08 #2
ju******@gmail.com wrote:
>
The code links some C++ libraries. It only hangs on AIX systems. But
for Linux, it works fine. Why?
Did you follow any of the advice given when you asked this on c.l.c?

--
Ian Collins.
Jan 21 '08 #3
On Jan 20, 7:23*pm, Ian Collins <ian-n...@hotmail.comwrote:
junw2...@gmail.com wrote:
The code links some C++ libraries. It only hangs on AIX systems. But
for Linux, it works fine. Why?

Did you follow any of the advice given when you asked this on c.l.c?

--
Ian Collins.
I find that one of the library that I link causes the problem. It
defines a static object. My code does not use that static object. When
exit the main(), the destructor is called and hangs.
But why it works on some systems?

Thanks.
Jan 21 '08 #4
ju******@gmail.com wrote:
On Jan 20, 7:23 pm, Ian Collins <ian-n...@hotmail.comwrote:
>junw2...@gmail.com wrote:
>>The code links some C++ libraries. It only hangs on AIX systems. But
for Linux, it works fine. Why?
Did you follow any of the advice given when you asked this on c.l.c?
*Please don't quote signatures*
>
I find that one of the library that I link causes the problem. It
defines a static object. My code does not use that static object. When
exit the main(), the destructor is called and hangs.
But why it works on some systems?
Hangs doing what?

It sounds like you have a platform issue rather than a language one.
The point where the hang occurs should provide your answer.

--
Ian Collins.
Jan 21 '08 #5
<ju******@gmail.comwrote in message
news:37**********************************@i12g2000 prf.googlegroups.com...
I find that maybe a C++ library causes the problem. What should I do?
When it "hangs", just attach it to a debugger and break. I think that you
can see where and why it "hangs"...

--

Pascal
Jan 21 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: deko | last post by:
I've heard it said that you only want to use a number (e.g. integer, long, etc.) if you are going to do calculations or some kind of math with it. Is this true? For example, I run a validate...
6
by: Ana | last post by:
Hi! I have problems with the following scenario: My application is developed using C# under .NET. It must run on all Windows versions starting from Windows 98. The user must open different...
8
by: Atanas Banov | last post by:
i ran onto this weirdness today: seems like close() on popen-ed (pseudo)file fails miserably with exception instead of returning exit code, when said exit code is -1. here is the simplest...
52
by: lovecreatesbeauty | last post by:
Why the C standard committee doesn't provide a standard implementation including the C compiler and library when the language standard document is published? C works on the abstract model of low...
58
by: Jorge Peixoto de Morais Neto | last post by:
I was reading the code of FFmpeg and it seems that they use malloc just too much. The problems and dangers of malloc are widely known. Malloc also has some overhead (although I don't know what is...
8
by: mast2as | last post by:
I am sure this topic has been discussed a thousand times and I read a few things about it today on the net. I also want to say I am trying to start a polemic here, I am just curious and willint to...
94
by: Samuel R. Neff | last post by:
When is it appropriate to use "volatile" keyword? The docs simply state: " The volatile modifier is usually used for a field that is accessed by multiple threads without using the lock...
173
by: Marty James | last post by:
Howdy, I was reflecting recently on malloc. Obviously, for tiny allocations like 20 bytes to strcpy a filename or something, there's no point putting in a check on the return value of malloc....
17
by: Jack | last post by:
My program is about several thousands lines. It takes arguements from the command line. If no arguement is given, it should simply exist. Below is the architectureof main() : int main(int argc,...
10
by: happyse27 | last post by:
Hi All, I got this apache errors(see section A1 and A2 below) when I used a html(see section b below) to activate acctman.pl(see section c below). Section D below is part of the configuration...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.