*BSD News Article 49285


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!simtel!news.kei.com!news.mathworks.com!newsfeed.internetmci.com!howland.reston.ans.net!Germany.EU.net!nntp.gmd.de!news.rwth-aachen.de!manray!not-for-mail
From: odiug@gom.informatik.rwth-aachen.de (Guido Muesch)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: porting Linux apps to BSD !
Date: 22 Aug 1995 22:10:12 GMT
Organization: RWTH -Aachen / Rechnerbetrieb Informatik
Lines: 24
Message-ID: <41dkk4$fbn@news.rwth-aachen.de>
References: <aak2.808728796@Ra.MsState.Edu>
NNTP-Posting-Host: manray.informatik.rwth-aachen.de
X-Newsreader: TIN [UNIX 1.3 950520BETA PL0]

Atif Ahmad Khan (aak2@Ra.MsState.Edu) wrote:

: "/kernel: pid 4166: myprogram: uid 65534: exited on signal 11"
This is a SIGSEGV.  Segmentation violation.  Access to a memory location
outside of your program.
A good candidate for this are the string and memory routines called
with a NULL pointer.  e.g.  strcmp(foo, bar) where foo and/or bar are
NULL-pointers.  Under Linux this works, because they remapped the zero
page, so they have a 0 at position 0.  Same holds for Solaris, I think.
The FreeBSD behavior is ok, because POSIX says, that the behavior for
NULL-pointers is undefined.
I personally prefer getting a SIGSEGV so that I can clean up my code. 
8-)

: Any general porting ideas would help, as this is my first major
: attempt to port C code between platforms.
I suggest the 'POSIX Programmers Guide' from O'Reilley, on how to write
(more) portable Software.
Also sticking to ANSI C helps a lot.  Making use of gcc compiler flags
'-Wall -ansi -pedantic' helped me to improve my code quality.

Keep on hacking 8-)
  Guido