Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Sep 1999 15:59:55 -0400
From:      "David E. Cross" <crossd@cs.rpi.edu>
To:        freebsd-hackers@freebsd.org
Subject:   perl stangeness on 3.3-RC
Message-ID:  <199909151959.PAA22581@cs.rpi.edu>

next in thread | raw e-mail | index | archive | help
We have a very hetergenous environment here (even among the FreeBSD boxes).
Each PC tends to be just a little bit different.  This expecially causes
problems since we wish to have XDM on each machine on boot and have X
on a NFS partition.  TO alleviate this we invented a simple Perl script
to replace /usr/X11R6/bin/X to run the correct program on each machine:


#!/usr/bin/perl -w
use Sys::Hostname;

read_servers();
$commandline="/usr/X11R6/bin/XF86_VGA16";
$host=hostname();
print STDERR "host is $host\n";
$screen=$ARGV[0];
$display= $host . $screen;
print STDERR "display is $display\n";
if ($server{$display}) {
 $commandline = join (' ', $server{$display}, @ARGV);
}
elsif ($server{$host}) {
 $commandline = join (' ',$server{$host}, @ARGV);
}
exec $commandline;

sub read_servers {
 open (XSERVERLIST, "/usr/local/etc/xservers");
 while ($hostline = <XSERVERLIST>) {
  chomp ($hostline);
  @fields = split ' ', $hostline, 2;
  $server{$fields[0]} = $fields[1];
 }
}

This worked fine up until about 3.3-RC, then it stopped with the following
error:

Use of uninitialized value at /usr/libdata/perl/5.00503/Sys/Hostname.pm line 100, <XSERVERLIST> chunk 13.
Use of uninitialized value at /usr/libdata/perl/5.00503/Sys/Hostname.pm line 109, <XSERVERLIST> chunk 13.
Can't exec "/com/host": No such file or directory at /usr/libdata/perl/5.00503/Sys/Hostname.pm line 115, <XSERVERLIST> chunk 13.
Cannot get host name of local machine at /usr/X11R6/bin/X line 6

Note that this is *only* a problem when this script is run by xdm by init.
If I run the script by hand, or I run xdm by hand it works OK.  Also consider
the results of a ktrace on init (PID 1) when xdm was started (alot of stuff
has been deleted to ease readability:


   445 perl     RET   execve 0

   445 perl forks and execs 'hostname'
	
   447 hostname RET   execve 0
   447 hostname CALL  __sysctl(0xbfbfdcd0,0x2,0xbfbfdcf8,0xbfbfdcd8,0,0)
   447 hostname RET   __sysctl 0
   447 hostname CALL  fstat(0x1,0xbfbfd9e4)
   447 hostname RET   fstat 0
   447 hostname CALL  readlink(0x8050a1c,0xbfbfd9e4,0x3f)
   447 hostname NAMI  "/etc/malloc.conf"
   447 hostname RET   readlink -1 errno 2 No such file or directory
   447 hostname CALL  mmap(0,0x1000,0x3,0x1002,0xffffffff,0,0,0)
   447 hostname RET   mmap 671424512/0x28052000
   447 hostname CALL  break(0x8055000)
   447 hostname RET   break 0
   447 hostname CALL  break(0x8059000)
   447 hostname RET   break 0
   447 hostname CALL  write(0x1,0x8055000,0x10)
   447 hostname GIO   fd 1 wrote 16 bytes
       "loot.cs.rpi.edu
       "
   445 perl     GIO   fd 1 read 16 bytes
       "loot.cs.rpi.edu
       "
   445 perl     RET   read 16/0x10
   445 perl     CALL  read(0x1,0x80e0000,0x4000)
   447 hostname RET   write 16/0x10
   447 hostname CALL  exit(0)
   446 sh       RET   wait4 447/0x1bf
   446 sh       CALL  exit(0)
   445 perl     GIO   fd 1 read 0 bytes
       ""
   445 perl     RET   read 0
   445 perl     CALL  close(0x1)
   445 perl     RET   close 0
   445 perl     GIO   fd 2 wrote 106 bytes
       "Use of uninitialized value at /usr/libdata/perl/5.00503/Sys/Hostname.p\
	m line 100, <XSERVERLIST> chunk 13.
       "
	.
	.
	.
   448 sh       NAMI  "/bin/uname"
   448 sh       RET   stat -1 errno 2 No such file or directory
   448 sh       CALL  stat(0x809ccb8,0xbfbfdc54)
   448 sh       NAMI  "/usr/bin/uname"
   448 sh       RET   stat 0
   448 sh       CALL  break(0x80a3000)

	.
	.
	.

   449 uname    RET   execve 0
   449 uname    GIO   fd 1 wrote 16 bytes
       "loot.cs.rpi.edu
       "
   445 perl     GIO   fd 1 read 16 bytes
       "loot.cs.rpi.edu
       "
   448 sh       RET   wait4 449/0x1c1
   448 sh       CALL  exit(0)
   445 perl     GIO   fd 1 read 0 bytes
       ""
   445 perl     RET   read 0
   445 perl     CALL  close(0x1)
   445 perl     RET   close 0
   445 perl     GIO   fd 2 wrote 106 bytes
       "Use of uninitialized value at /usr/libdata/perl/5.00503/Sys/Hostname.p\
	m line 109, <XSERVERLIST> chunk 13.
       "
   450 perl     CALL  execve(0x80dd140,0x808c2e0,0x8076e80)
   450 perl     NAMI  "/com/host"
   450 perl     RET   execve -1 errno 2 No such file or directory
   450 perl     CALL  write(0x2,0x8070e00,0x81)
   450 perl     GIO   fd 2 wrote 129 bytes
       "Can't exec "/com/host": No such file or directory at /usr/libdata/perl\
	/5.00503/Sys/Hostname.pm line 115, <XSERVERLIST> chunk 13.
       "
   450 perl     RET   write 129/0x81
   450 perl     CALL  exit(0x1)
       "Cannot get host name of local machine at /usr/X11R6/bin/X line 6
       "

Any ideas what is going on here?  It looks like it gets what it wants and then
just ignores it?!?

--
David Cross                               | email: crossd@cs.rpi.edu 
Systems Administrator/Research Programmer | Web: http://www.cs.rpi.edu/~crossd 
Rensselaer Polytechnic Institute,         | Ph: 518.276.2860            
Department of Computer Science            | Fax: 518.276.4033
I speak only for myself.                  | WinNT:Linux::Linux:FreeBSD


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199909151959.PAA22581>