Hi Everyone

It was my being an Ass uming person.   My objective was that the program name 
be that which was listed in the directory. Change the program name and the 
error messages with the name change as well.

In the first lines of C code I had

char *progName= 1 + strrchr(argv[0],'/');   //Want one to the right of the 
right most slash          

This worked fine as I was always testing in the directory where I created the 
program . (always need to prepend ./)

The corrected code will be clear to you at once about what I overlooked.

char *cp,*progName

progName=argv[0];
if (NULL != (cp=strrchr(argv[0],'/')))
   progName = cp+1;

When the program is activated via the $PATH,  there is no path prepending the 
program name and hence, no path,  just a progName;

Sorry to bother you with such a trivial boo boo.

Regards

 Leslie
 Mr. Leslie Satenstein
50 years in Information Technology and going strong.
Yesterday was a good day, today is a better day,
and tomorrow will be even better.
 
mailto:[email protected]
alternative: [email protected] 
www.itbms.biz  www.eclipseguard.com
 

--- On Wed, 10/31/12, Jérôme Oufella <[email protected]> 
wrote:

From: Jérôme Oufella <[email protected]>
Subject: Re: [MLUG] How to stop programs generating segmentation error messages 
on exit
To: "Montreal Linux Users Group" <[email protected]>, "Leslie S Satenstein" 
<[email protected]>
Date: Wednesday, October 31, 2012, 9:15 AM



Chances are you are overflowing your main function stack. Gdb is
your best asset to watch the what's going on.




On 30 octobre 2012 21:42:32 Leslie S Satenstein
 wrote:



 

Regards
 
 Leslie
 Mr. Leslie
Satenstein
50 years
in Information Technology and going strong.
Yesterday was a good
day, today is a better day,
and tomorrow will be even
 better.
 
mailto:[email protected]
alternative:
[email protected] 
www.itbms.biz 
www.eclipseguard.com



--- On Tue,
10/30/12, Jérôme Oufella
<[email protected]>
wrote:

From:
Jérôme Oufella <[email protected]>
Subject:
Re: [MLUG] How to stop programs generating segmentation error messages
on exit
To: "Montreal Linux Users Group"
<[email protected]>
Date: Tuesday, October 30, 2012, 5:47
PM

Hi Leslie,

Have the programs
been compiled on the same environment as the one they are running
 ?

Jerome

Hi Guys,

My home dir is leslie

In
responding to your questions, 

Yes, I am preparing software for
32 and 64 bit systems. I have the same source and makefile on each
system for each sized compiler. The command  echo $PATH
shows  /home/leslie/bin as being in it with appropriate ownerships
and accesses  With Ubuntu   /home/leslie/bin first
before the rest of the $PATH entries.  In Fedora  it is at
the end.

my program is called
desfed      and without arguments, it just
issues an info message and exits with exit(EXIT_SUCCESS);
The
exit(EXIT_SUCCESS) was calling an atexit() function. I temporarily
removed
the atexit() call and the same problem remains.
The code
I use calls malloc, but here again, it is for dynamically fixed size
items. Any overrun with malloc would have burped with a memory dump.
This is not the problem as the info message
 does not do malloc calls, It is just a series of a few printf
commands.

Some of the things I tried.

If I create a one
line shell script and all it has on one line alone is desfed, I get a
segmentation error.

if I add the path as   
/home/leslie/bin/desfed        all
works OK.

I am beginning to suspect a faulty gcc library
entry.  One function I am using is a system function realpath(),
which provides for the expansion of path names such as  "../../"
etc. realpath does do malloc calls. My program, without arguments goes
directly to print the info stuff.

Googling failed to give me the
answer. So, I will be exploring what is the reason using the qualified
name /home/leslie/bin/desfed   works whereas 
desfed   alone does not.  Otherwise the code passes all
my test scripts, of which there are many.

I thought perhaps you had this
 problem before, and knew what to do.
I am running in terminal mode,
under gnome 3.6 and with Unity 12,04 under the LTS version (both 32 and
64 bit modules produce correct
results).

_______________________________________________
mlug
mailing list
[email protected]
https://listes.koumbit.net/cgi-bin/mailman/listinfo/mlug-listserv.mlug.ca



_______________________________________________
mlug mailing list
[email protected]
https://listes.koumbit.net/cgi-bin/mailman/listinfo/mlug-listserv.mlug.ca

Reply via email to