473,809 Members | 2,712 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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"<<end l;
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 5381
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"<<end l;
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.co mwrote:
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.co mwrote:
>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******** *************** ***********@i12 g2000prf.google groups.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
1797
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 routine that checks an address entry - if something's missing in the entry, the code does different things based on what is missing, indicated my a 2 or a 3 - integer values. Should I use string data types here? Does it matter? Public Sub...
6
5174
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 documents (txt, MS Office files, pdf, pictures,…) from inside my app. It must start the file with the adequate external program (Notepad, MS Office programs, Acrobat Reader, some Picture viewer,... ) and be notified when this programs closes the...
8
3745
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 example (under Windows): >>> print popen('exit 1').close() 1 >>> print popen('exit -1').close() Traceback (most recent call last):
52
3802
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 level machine. C stands for portability and platform and machine independent. If the C compiler and C standard library are written in C itself, is it possible that one "standard" C compiler plus library is enough? The standard implementation is...
58
4698
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 the overhead of automatic variable sized arrays, I suspect it is smaller than that of malloc), although I'm not too worried about it. I was thinking that, with C99's variable length arrays, malloc shouldn't be needed most of the time. But I'm...
8
2460
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 learn and improve the way I am approaching some coding issues that I have at the moment. I use C++ programming for my work, but I am not a developper so please be patient & tolerant in your answers ;-) Okay for the last few days I have been...
94
30385
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 Statement (C# Reference) statement to serialize access. " But when is it better to use "volatile" instead of "lock" ?
173
8207
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. OTOH, if you're allocating a gigabyte for a large array, this might fail, so you should definitely check for a NULL return.
17
391
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, char *argv) { if( argc == 1 ) { printf("NO ARGUEMENT\n");
10
6983
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 of section c. Not sure where went wrong as the web page displayed internal server error. Also, what is the error 543? and error 2114. Where to find the list of errors in websites as it is not the standard apache error. I could not find...
0
10635
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10378
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10115
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7653
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3013
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.