Linux-Development-Apps Digest #366, Volume #7    Sat, 28 Apr 01 20:13:11 EDT

Contents:
  Re: Is libc.so is linked to all process who need it seperatly ? (David Konerding)
  Re: java run time warning problem (Robert Lynch)
  sockets ("Darren")
  Re: Shell script as root cron job (Floyd Davidson)
  Re: sockets (Rene Herman)
  Asynchronous sockets ("Kristian Kismul")
  Re: Asynchronous sockets ("Kristian Kismul")
  Re: sockets ("Neil Butterworth")
  Re: Loading Dynamic Libraries written in C++ from C with Linux ("D. Stimits")
  Trouble with pipe implementation ("Frank L. Liao")
  Parser for x86 assembly for Source Navigator ("xxxoltan")
  Re: sockets ("Darren")
  Re: ifconfig command (Sachio)
  fd_set and C++ vector (Steve Connet)
  Re: pthread_cond_wait + select question (Steve Connet)

----------------------------------------------------------------------------

From: [EMAIL PROTECTED] (David Konerding)
Subject: Re: Is libc.so is linked to all process who need it seperatly ?
Date: 28 Apr 2001 17:05:13 GMT
Reply-To: [EMAIL PROTECTED]

On 28 Apr 2001 05:54:40 GMT, hushui <[EMAIL PROTECTED]> wrote:
> 
> I have seen the file in /proc/self/maps .
> It is the virtual address of the running process.
> To th process /bin/bash 
> 
> 08048000-08091000 r-xp 00000000 03:03 31591      /bin/bash
> 08091000-08097000 rw-p 00048000 03:03 31591      /bin/bash
> ...........
> 4001f000-4010c000 r-xp 00000000 03:03 188944     /lib/libc-2.1.3.so
> 4010c000-40110000 rw-p 000ec000 03:03 188944     /lib/libc-2.1.3.so
> 40110000-40114000 rw-p 00000000 00:00 0
> ...............
> To the process mingetty
> 
> 08048000-0804a000 r-xp 00000000 03:03 48355      /sbin/mingetty
> 0804a000-0804b000 rw-p 00001000 03:03 48355      /sbin/mingetty
> ............
> 
> 4001b000-40108000 r-xp 00000000 03:03 188944     /lib/libc-2.1.3.so
> 40108000-4010c000 rw-p 000ec000 03:03 188944     /lib/libc-2.1.3.so
> 4010c000-40110000 rw-p 00000000 00:00 0
> bfffe000-c0000000 rwxp fffff000 00:00 0
> 
> From above ,libc.so is loaded to different address of the different process.
> Since libc.so is need by many program,it is linked to every process adress space 
>seperately ,or loaded only once and shared by all process ???


they're all linked and shared in read-only pages.  They use
relative offsets so that that code does not need to be
relocated at map time.  

The reason they can't all be loaded to the same location
is that you can't really reserve a location for the library
if you don't know what size it will be at load-time (you
might update libc.so with a much larger version, and it would
overwrite some library mapped to a location after it.

This is whats great about position independent code; it
does have a performance hit however.
d

------------------------------

From: Robert Lynch <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
Subject: Re: java run time warning problem
Date: Sat, 28 Apr 2001 10:49:44 -0700

Jinsong Liang wrote:
> 
> Hi all,
> 
> I am using RH6.2 and JDK1.3. Whenever I run any Java program, following
> lines show up on screen:
> 
> Font specified in font.properties not found
> [--symbol-medium-r-normal--*-%d-*-*-p-*-adobe-fontspecific]
> 
> What's the problem?
> 
> Thanks in advance.
> 
> Leo

This has been around for ages.  See for example:

http://www.blackdown.org/java-linux/docs/support/faq-release/FAQ-java-linux-6.html#ss6.4

for a discussion of it.

HTH. Bob L.
-- 
Robert Lynch     Berkeley CA USA    [EMAIL PROTECTED]


------------------------------

From: "Darren" <[EMAIL PROTECTED]>
Crossposted-To: 
comp.os.linux.development.system,linux.redhat.devel,linux.redhat.development
Subject: sockets
Date: Sat, 28 Apr 2001 19:09:28 +0100

Hello. I am looking for some info on socket programming for Linux. I assume
from the man pages it is similar to Winsock programming. Can anyone direct
me to a decent document on the subject as I find the man pages lacking

Thank you

Darren




------------------------------

From: Floyd Davidson <[EMAIL PROTECTED]>
Subject: Re: Shell script as root cron job
Date: 28 Apr 2001 09:58:10 -0800

<[EMAIL PROTECTED]> wrote:
>I am trying to run a shell script as a root cron job ...

Explicitly set the PATH variable in the shell script, and
include the directories for any and all commands that the
script uses.  Commonly there are several directories that
your login shell may include in the PATH variable which are
not added for a non-interactive shell run by cron.

  PATH=/usr/local/bin:/bin:/usr/bin/:/sbin:/usr/sbin

Another way is to call all commands using the full pathname,
and that can easily be done by using variables that are
configured at the top of a shells script.

   #!/bin/sh
   #
   GREP="/usr/bin/grep -w"
   LS=/bin/ls

   ${LS} /bin | ${GREP} ls


-- 
Floyd L. Davidson         <http://www.ptialaska.net/~floyd>
Ukpeagvik (Barrow, Alaska)                 [EMAIL PROTECTED]

------------------------------

From: Rene Herman <[EMAIL PROTECTED]>
Crossposted-To: 
comp.os.linux.development.system,linux.redhat.devel,linux.redhat.development
Subject: Re: sockets
Date: Sat, 28 Apr 2001 21:35:58 +0200

Darren wrote:

[ Followup-To set ]

> Hello. I am looking for some info on socket programming for Linux.

The most frequently mentioned book on the subject is "UNIX Network 
Programming" by W. Richard Stevens. It's ridiculously expensive.

> I assume from the man pages it is similar to Winsock programming.

Since Windows Sockets were modelled after (ie, copied from) regular BSD 
UNIX sockets, this is true. Sockets originated in BSD and found their 
way into the other unices and many other systems, including Windows.

> Can anyone direct me to a decent document on the subject as I find
> the man pages lacking

The single best thing you can do is study existing socket source code. 
Fortunately, with Linux being as open source as it is, there are many 
good examples available. The next thing you'll want to do is subscribe 
to comp.unix.programmer and check out their socket faq at:

http://www.lcg.org/sock-faq/

Posting questions to c.u.p is likely to yield many good answers. Many 
good TCP/IP programmers (of which I am not one) hang out there...

Hope this helps,
Rene Herman

------------------------------

From: "Kristian Kismul" <[EMAIL PROTECTED]>
Subject: Asynchronous sockets
Date: Sat, 28 Apr 2001 20:06:25 GMT

I'm in need of information on how to work with asynchronous sockets in
BSD-sock under Linux. Any help / code examples / url's / book suggestions
are very welcome!

.Kristian.



------------------------------

From: "Kristian Kismul" <[EMAIL PROTECTED]>
Subject: Re: Asynchronous sockets
Date: Sat, 28 Apr 2001 20:10:59 GMT

Oh, and i almost forgot. I'm programming in C : )



------------------------------

From: "Neil Butterworth" <[EMAIL PROTECTED]>
Subject: Re: sockets
Date: Sat, 28 Apr 2001 21:01:09 +0100

"Darren" <[EMAIL PROTECTED]> wrote in message
news:AJDG6.2653$[EMAIL PROTECTED]...
> Hello. I am looking for some info on socket programming for Linux. I
assume
> from the man pages it is similar to Winsock programming. Can anyone direct
> me to a decent document on the subject as I find the man pages lacking

Not a bad book is "Linux Socket Programming" by Sean Walton, ISBN
0-672-31935-7 _provided_ you ignore his thoughts on C++ programming, about
which he obviously knows very little. Most of the book is about socket
programming in C. Don't get this mixed up with one of Que's "by exampl"
books, which I thought was crap.

BTW, Linux and Windows socket programming is similar in concept but
annoyingly different in the details.

NeilB

PS You seem to have cross-posted this rather a lot - I'm only repplying in
the apps newsgroup..



------------------------------

Date: Sat, 28 Apr 2001 15:13:28 -0600
From: "D. Stimits" <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
Subject: Re: Loading Dynamic Libraries written in C++ from C with Linux

Massimiliano Trezzi wrote:
> 
> Hi,
> 
> I'm porting an UDF library for Interbase from Win to Linux.
> Ad UDF library in Windows it's a DLL with some exported function with as C
> functions.
> I wrote them with C++ and I exported them using extern "C" keyword, but
> Interbase looks them as C functions.
> With linux I have a problem accessing the library Interbase does not
> recognize it. If I make a C library all it's ok.
> I saw that it's a generic problem (not from Interbase) when accesing to
> dynamic C++ library from a C program.

dlopen() always assumes unmangled names, whereas C++ mangles anything
not extern "C". However, within the library code it will always be able
to see its own symbols; if you create a wrapper that is extern "C" to
get a pointer to the C++ versions, you can use dlopen to get a pointer
to the proper C++ version, or return a pointer to an object of the
proper type (a C wrapper to a factory is nice here).

There is a good article about this and some of the problems that was in
the Linux Journal, issue 73, March 29, 2000:
http://www2.linuxjournal.com/cgi-bin/frames.pl/index.html

>From that index page, do a search for "self-registering".

The method discussed is fairly portable as well. Although there may be
other ways to do this, such as discovering the mangled name and calling
dlsym using the mangled version, name mangling is changing and won't be
consistent or portable, even among some distributions of linux.

D. Stimits, [EMAIL PROTECTED]

> 
> I'm using RedHat 7.1 the gcc compiler and the ld linker and now the makefile
> is:
> 
> # let's call it LA (note: this uses STANDARD C++ LIBRARIES)
> INGlobals: INGlobals.o NumUdf.o Stringudf.o
>     ld -o INGlobals INGlobals.o NumUdf.o Stringudf.o -shared -lgds
> INGlobals.o: INGlobals.cpp
>     g++ -c -fPIC INGlobals.cpp
> NumUdf.o: NumUdf.cpp
>     g++ -c -fPIC NumUdf.cpp
> Stringudf.o: StringUdf.cpp
>     g++ -c -fPIC StringUdf.cpp
> 
> I made other two versions of the library:
>  LB: with C++, but using some simple classes without Standard Libraries.
>  LC: with pure C (that made with gcc)
> 
> I made trhee little programs that access the libraries:
>  PA: C++ program statically linked to LA
>  PB: C++ program that uses dl library routines (dlopen(),dlsym(),etc.)
>  PC: pure C program that uses dl library routines (dlopen(),dlsym(),etc.)
> 
> I know that the library exports clear function name by using the nm utility,
> bu I have these results:
> 
> All it's ok when
>  PA access to LA
>  PB access dynamically to LA, LB (i did not try with LC)
>  PC access dynamically to LC
> 
> I get no handle from dlopen() when:
>  PC access to LA
> 
> I get the handle, but I get a "Segmentation Fault" when:
>  PC tried to use a function exported from LB
> 
> I'm sure that when I'l be able to access from PC to LA  I'll be able to get
> the library wortking as an UDF library on Interbase.
> 
> Is there anybody who can help me?
> 
> Thank you in advance,
>  Massimiliano Trezzi

------------------------------

From: "Frank L. Liao" <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.system
Subject: Trouble with pipe implementation
Date: Sat, 28 Apr 2001 14:25:51 -0700

Hi guys,

I'm currently having a problem implmenting pipe into a custom shell I'm
writing.  It seems that when I do "ls | cat", it seems to be fine.
Though, when I call "ls | cat | netscape" it seems to hang on "cat".
Then, I try it again.  "ls | cat" works.  Then, I tried "ls | cat"
again, it would hang.  What am I doing wrong here?

Frank
TIA

/* The code I made is on the bottom.  pList is a link list of structs
which contains argv and argc.  nPipes is the number of Pipe operators
(not operands) that I'm going to execute.  So, if nPipe = 1, then there
are two argv's that need to be executed. */

void ExecutePipe(struct CmdLine *pList, int nPipes)
{
 int i;
 int fidPipe[2];
 enum PIPES { READ, WRITE }; /* Constants 0 and 1 for READ and WRITE */
 struct CmdLine *pCurrent = pList;

 pipe(fidPipe);

 for(i = 0; i < nPipes + 1; i++) {
  if(i == nPipes) {
   /* If this is the last program to be executed, we need to close the
write pipe
         before continuing, since we have no need for this pipe anymore.
*/
   close(fidPipe[WRITE]);
   if(fork() == 0) {
    /* Close current stdin to keyboard */
    close(fileno(stdin));
    /* copy the handle of the pipe to stdin*/
    dup(fidPipe[READ]);
    /* now close the handle of the pipe. So that only stdin/pipe is
open*/
    close(fidPipe[READ]);

    execvp(pCurrent->argv[0], pCurrent->argv);
   } else {
    int status;
    wait(&status);
   }
  } else {
   if(fork() == 0) {
    if(i != 0) {
     /* if we are in the middle of a pipe, stdin should be closed and be
converted to
        the read of the pipe. */
     close(fileno(stdin));
     dup(fidPipe[READ]);
    }
    /* Now, close the read end of the pipe since we don't need it */
    close(fidPipe[READ]);
    /* Close stdout, which would be redircted the the write end of the
pipe */
    close(fileno(stdout));
    dup(fidPipe[WRITE]);
    /* Close the write pipe, which we don't need */
    close(fidPipe[WRITE]);

    execvp(pCurrent->argv[0], pCurrent->argv);
   } else {
    int status;
    wait(&status);
   }
  }
  pCurrent = pCurrent->pNextNode;

 }

 return;
}


------------------------------

From: "xxxoltan" <[EMAIL PROTECTED]>
Crossposted-To: comp.lang.asm.x86,comp.os.linux.answers
Subject: Parser for x86 assembly for Source Navigator
Date: Sat, 28 Apr 2001 21:49:37 +0000 (UTC)

Howdy,

Does anyone know of the existence of an assembly language parser for X86
assembly to integrate with Source Navigator?  I "could" modify the existing
PowerPC601 assembly parser that comes with SN, but I'm hoping someone
already beat me to that.  It would be nice if it followed MASM (yeccchhh!)
syntax.

Also, as long as I'm wishing, I also wish for a make file parser, possibly
to integrate with SN, but something on the order of Sun's makefile analyzer
that comes with their development tools would be nice.  Has anyone heard of
such a beast?

Thanks,
xxxoltan (wallowing in legacy...quite against my will)


------------------------------

From: "Darren" <[EMAIL PROTECTED]>
Subject: Re: sockets
Date: Sat, 28 Apr 2001 22:44:39 +0100


Rene Herman <[EMAIL PROTECTED]> wrote in message
news:9cf646$hfj$[EMAIL PROTECTED]...
> Darren wrote:
>
> [ Followup-To set ]
>
> > Hello. I am looking for some info on socket programming for Linux.
>
> The most frequently mentioned book on the subject is "UNIX Network
> Programming" by W. Richard Stevens. It's ridiculously expensive.

they usually are

>
> > I assume from the man pages it is similar to Winsock programming.
>
> Since Windows Sockets were modelled after (ie, copied from) regular BSD
> UNIX sockets, this is true. Sockets originated in BSD and found their
> way into the other unices and many other systems, including Windows.
You can't supress a good thing, though it is no suprise that yet another of
unix's main atributes was adopted by windows

>
> > Can anyone direct me to a decent document on the subject as I find
> > the man pages lacking
>
> The single best thing you can do is study existing socket source code.

A while ago i wrote some winsock stuff which worked well but i lost all my
reference material. I remember the sequence but i forget the constants

> Fortunately, with Linux being as open source as it is, there are many
> good examples available. The next thing you'll want to do is subscribe
> to comp.unix.programmer and check out their socket faq at:

I will subscribe and have subscribed :-)

>
> http://www.lcg.org/sock-faq/
>
> Posting questions to c.u.p is likely to yield many good answers. Many
> good TCP/IP programmers (of which I am not one) hang out there...

Do not put yourself down. you have the wisdom of programmers

>
> Hope this helps,
> Rene Herman

It did Rene. you have been very helpful. Thank you

Darren



------------------------------

From: Sachio <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.system
Subject: Re: ifconfig command
Date: Sat, 28 Apr 2001 23:13:23 GMT

Thanks, Peter, my response is mixed in with yours, please, scroll down.

"Peter T. Breuer" wrote:

> In comp.os.linux.development.apps Sachio <[EMAIL PROTECTED]> wrote:
> > When you execute 'ifconfig' with no other arguments, where does the
> > utility retrieve the information from?  I have one network adapter that
>
> From the kernel. It reports all "up" interfaces.
>

Yes, I understand that.   The question now would be where does the
kernel store it?  Is there a config file of some sort?


> > is dhcp, and I'm wanting to find out where ifconfig retrieves the
> > assigned ip from.
>
> It makes ioctls on a socket to get the information about each interface
> in turn.

> > Also, which directory/file contains the source code for the ifconfig utility?
>
> The one called ifconfig.c (and more). Download the source code for your
> ifconfig and you will see.

Ok, good!  I thought there might be a source file by that name.  I searched on
my system, but I guess I don't have that one stored on my drive.  I'll go get it.

Thanks, again, Peter!



------------------------------

Subject: fd_set and C++ vector
From: Steve Connet <[EMAIL PROTECTED]>
Date: Sat, 28 Apr 2001 23:34:19 GMT


Of all the fd's I put in my fd_set, only the last fd I put in (and the
listening fd) ever get triggered on select. Any ideas? I don't know
what's wrong.


I have a vector of pointers:

vector<CClient*> client_vec;

The class has a method to get the file descriptor:

int CClient::fd() const { return _fd; }

I have a file descriptor which is the listening socket. I aad that to
a fd_set, called read_set. Select returns and the fd is set when a new
client arrives. I accept, create a new client, and put him in my
client_vec. I then add to the set like this:

client_vec.push_back(new CClient(... stuff & fd ...));
FD_SET(new_client->fd(), &read_set);

So far so good. It works. When there is a new connection select
returns, and when the new client sends data the select returns. I can
process each case.

However, the problem is when a 2nd client connects. I accept the
connection and do the same thing:

client_vec.push_back(new CClient(... stuff & fd ...));
FD_SET(new_client->fd(), &read_set);

The select now returns for new connections and the last client I put
in the set. Previous clients in the set (yes I put them back in the
set after reading from them) aren't set when select returns, even
though I KNOW they are sending data. I wrote the test client driver.

What am I missing? I do a:

... iterate through all clients in the vector ...
if(FD_ISSET(current_client->fd(), &read_set) {
  FD_CLR(current_client->fd());

  .. read the data and do something ...

  // put back in the set
  FD_SET(current_client->fd(), &read_set);
]

-- 
Steve Connet            Remove USENET to reply via email
[EMAIL PROTECTED]

------------------------------

Subject: Re: pthread_cond_wait + select question
From: Steve Connet <[EMAIL PROTECTED]>
Date: Sat, 28 Apr 2001 23:40:06 GMT

"Robben Mario" <[EMAIL PROTECTED]> writes:

> Is there an easy way on how to wait for a condition variable + some
> filedescriptor is ready for reading/writing. What I need is a function like
> "pthread_cond_wait_select".
> 
> Is there a function available on how to wait for several condition variables
> (e.g. in Win32 you have a function WaitForMultipleObjects).

What I do is open a pipe and put the read fd of the pipe in the
fd_set. When I want to trigger select, I write to the write fd of the
pipe. Select returns, I check the read fd of the pipe, and if it's set
(using FD_ISSET) then I know I've been triggered internally.


-- 
Steve Connet            Remove USENET to reply via email
[EMAIL PROTECTED]

------------------------------


** FOR YOUR REFERENCE **

The service address, to which questions about the list itself and requests
to be added to or deleted from it should be directed, is:

    Internet: [EMAIL PROTECTED]

You can send mail to the entire list by posting to the
comp.os.linux.development.apps newsgroup.

Linux may be obtained via one of these FTP sites:
    ftp.funet.fi                                pub/Linux
    tsx-11.mit.edu                              pub/linux
    sunsite.unc.edu                             pub/Linux

End of Linux-Development-Apps Digest
******************************

Reply via email to