[29735] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 979 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 26 14:10:20 2007

Date: Fri, 26 Oct 2007 11:09:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 26 Oct 2007     Volume: 11 Number: 979

Today's topics:
    Re: daemon in perl <tzz@lifelogs.com>
    Re: daemon in perl xhoster@gmail.com
    Re: How to interactively sending the username/password   cyrusgreats@gmail.com
    Re: Implementation of file input operator <> xhoster@gmail.com
        IPC::Open3 and the error filehandle <peter@makholm.net>
    Re: packing a C structure (Greg Bacon)
    Re: packing a C structure <jl_post@hotmail.com>
    Re: PID of exec <glex_no-spam@qwest-spam-no.invalid>
    Re: PID of exec xhoster@gmail.com
    Re: PID of exec  hendedav@gmail.com
    Re: PID of exec  hendedav@gmail.com
    Re: PID of exec <1usa@llenroc.ude.invalid>
        see the riboosomes pics and information  harivasantha04@gmail.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 26 Oct 2007 06:13:41 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: daemon in perl
Message-Id: <m23avyqgbe.fsf@lifelogs.com>

On Thu, 25 Oct 2007 22:27:50 -0700 kaustabh.banerjee@gmail.com wrote: 

kb> I have a perl daemon which queries the DB in every 10 secs and checks
kb> some data. The daemon runs fine for most of the time, but dies
kb> sometimes with some DB exceptions. I have put eval block to survive
kb> this.

kb> But still it breaks sometimes.

kb> How to survive any exception at all. I just want to run no matter
kb> what..

(you should really find and fix your bug, as Josef Moellers suggested)

Use fork() to start a copy of your program, then *in the copy* do the
dangerous work.  Use IPC if the parent process must know what the child
is doing.  Make sure you wait for the child process.  See `perldoc -f
fork' and all the related documentation for more information.

Ted


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

Date: 26 Oct 2007 16:05:55 GMT
From: xhoster@gmail.com
Subject: Re: daemon in perl
Message-Id: <20071026120556.974$Av@newsreader.com>

kaustabh.banerjee@gmail.com wrote:
> I have a perl daemon which queries the DB in every 10 secs and checks
> some data. The daemon runs fine for most of the time, but dies
> sometimes with some DB exceptions. I have put eval block to survive
> this.
>
> But still it breaks sometimes.

Have you considered scotch tape?  Or at least telling us what errors you
are getting?

>
> How to survive any exception at all. I just want to run no matter
> what..

If the database server is on fire, exactly what is the client supposed to
do?  If you want your program to "run" no matter what, even if it doesn't
do anything useful, then replace all the code with "sleep while 1"

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.


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

Date: Fri, 26 Oct 2007 16:08:34 -0000
From:  cyrusgreats@gmail.com
Subject: Re: How to interactively sending the username/password to login using ssh
Message-Id: <1193414914.675592.66580@q5g2000prf.googlegroups.com>

On Oct 25, 5:05 pm, all mail refused <elvis-85...@notatla.org.uk>
wrote:
> On 2007-10-25, cyrusgre...@gmail.com <cyrusgre...@gmail.com> wrote:
>
> > I'm trying to interactively sending the username/password to login and
>
> passwordless logins are in the SSH docs and FAQ
>  http://www.snailbook.com/faq/
>
> "expect" deals with terminal input if you really need
> to provide a password that way.  Various CPAN modules
> involve it.
>  http://search.cpan.org/search?query=expect&mode=module
>
> --
> Elvis Notargiacomo  master AT barefaced DOT cheekhttp://www.notatla.org.uk/goen/

Thanks to you all I got it now.



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

Date: 26 Oct 2007 16:13:20 GMT
From: xhoster@gmail.com
Subject: Re: Implementation of file input operator <>
Message-Id: <20071026121322.388$YE@newsreader.com>

Uri Guttman <uri@stemsystems.com> wrote:
> >>>>> "hg" == himanshu garg <himanshu.garg@gmail.com> writes:
>
> hg>      There was a race condition in which the child process died
> during hg> the second read call and the parent kept waiting. Using a
> signal hg> handler for SIGCHLD required many code changes. Using sysread,
> I no hg> longer see the error.
>
> this sounds like you are reading from a pipe connected to the child.

But in that case the parent end of the pipe should be set eof when the
child dies, causing read to unblock.  Or at least that is the why the pipes
I've used behaved.  It sounds like something more weird than a simple pipe.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.


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

Date: Fri, 26 Oct 2007 13:33:07 +0000
From: Peter Makholm <peter@makholm.net>
Subject: IPC::Open3 and the error filehandle
Message-Id: <877ilaj90s.fsf@hacking.dk>

I'm trying to use IPC::Open3 but have some problem with the error
filehandle not being used. Try the following script:

  #!/usr/bin/perl

  use IPC::Open3;
  use Data::Dumper;

  my ( $in, $out, $err );
  open3($in,$out,$err, "/usr/bin/sort");

  print Dumper [$in, $out, $err];

  __END__


I would expect output like:

  $VAR1 = [
            \*Symbol::GEN0,
            \*Symbol::GEN1,
            \*Symbol::GEN2,
          ];

but I get output like

  $VAR1 = [
            \*Symbol::GEN0,
            \*Symbol::GEN1,
            undef
         ];


Reading the documentation, it clearly states that: 

  If CHLD_ERR is false, or the same file descriptor as CHLD_OUT, then
  STDOUT and STDERR of the child are on the same filehandle.  The
  CHLD_IN will have autoflush turned on. 

and $err is undef, which is clearly false. But what would be the
correct way to call open3?

The following works:

  #!/usr/bin/perl

  use IPC::Open3;
  use Symbol;
  use Data::Dumper;

  my ( $in, $out, $err );
  $err = gensym;
  open3($in,$out,$err, "/usr/bin/sort");

  print Dumper [$in, $out, $err];

  __END__

but calling gensym by hand seems oldschool. But is there a better way?

//Makholm


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

Date: Fri, 26 Oct 2007 16:09:36 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: packing a C structure
Message-Id: <13i44a0rubn1nba@corp.supernews.com>

In article <1193374675.362127.274760@i38g2000prf.googlegroups.com>,
     <haairam@gmail.com> wrote:

: iam trying to pack a C structure to send via socket..i would like to
: know how to frame the template for the C structure.. [...]

Is another program sending the data currently? If so, how are you
doing it?

Consider writing an extension, such as the one in the shell archive
below.

Enjoy,
Greg

#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.7).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `#!/bin/sh' line above, then type `sh FILE'.
#
lock_dir=_sh03320
# Made on 2007-10-26 11:05 CDT
# Source directory was `/tmp'.
#
# Existing files will *not* be overwritten, unless `-c' is specified.
#
# This shar contains:
# length mode       name
# ------ ---------- ------------------------------------------
#    277 -rw-r--r-- MyData/lib/MyData.pm
#    766 -rw-r--r-- MyData/Makefile.PL
#     56 -rw-r--r-- MyData/MANIFEST
#    947 -rw-r--r-- MyData/MyData.xs
#    977 -rw-r--r-- MyData/t/MyData.t
#
MD5SUM=${MD5SUM-md5sum}
f=`${MD5SUM} --version | egrep '^md5sum .*(core|text)utils'`
test -n "${f}" && md5check=true || md5check=false
${md5check} || \
  echo 'Note: not verifying md5sums.  Consider installing GNU coreutils.'
save_IFS="${IFS}"
IFS="${IFS}:"
gettext_dir=FAILED
locale_dir=FAILED
first_param="$1"
for dir in $PATH
do
  if test "$gettext_dir" = FAILED && test -f $dir/gettext \
     && ($dir/gettext --version >/dev/null 2>&1)
  then
    case `$dir/gettext --version 2>&1 | sed 1q` in
      *GNU*) gettext_dir=$dir ;;
    esac
  fi
  if test "$locale_dir" = FAILED && test -f $dir/shar \
     && ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
  then
    locale_dir=`$dir/shar --print-text-domain-dir`
  fi
done
IFS="$save_IFS"
if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED
then
  echo=echo
else
  TEXTDOMAINDIR=$locale_dir
  export TEXTDOMAINDIR
  TEXTDOMAIN=sharutils
  export TEXTDOMAIN
  echo="$gettext_dir/gettext -s"
fi
if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null
then if (echo -n test; echo 1,2,3) | grep n >/dev/null
     then shar_n= shar_c='
'
     else shar_n=-n shar_c= ; fi
else shar_n= shar_c='\c' ; fi
f=shar-touch.$$
st1=200112312359.59
st2=123123592001.59
st2tr=123123592001.5 # old SysV 14-char limit
st3=1231235901

if touch -am -t ${st1} ${f} >/dev/null 2>&1 && \
   test ! -f ${st1} && test -f ${f}; then
  shar_touch='touch -am -t $1$2$3$4$5$6.$7 "$8"'

elif touch -am ${st2} ${f} >/dev/null 2>&1 && \
   test ! -f ${st2} && test ! -f ${st2tr} && test -f ${f}; then
  shar_touch='touch -am $3$4$5$6$1$2.$7 "$8"'

elif touch -am ${st3} ${f} >/dev/null 2>&1 && \
   test ! -f ${st3} && test -f ${f}; then
  shar_touch='touch -am $3$4$5$6$2 "$8"'

else
  shar_touch=:
  echo
  ${echo} 'WARNING: not restoring timestamps.  Consider getting and'
  ${echo} 'installing GNU `touch'\'', distributed in GNU coreutils...'
  echo
fi
rm -f ${st1} ${st2} ${st2tr} ${st3} ${f}
#
if test ! -d ${lock_dir}
then : ; else ${echo} 'lock directory '${lock_dir}' exists'
  exit 1
fi
if mkdir ${lock_dir}
then ${echo} 'x - created lock directory `'${lock_dir}\''.'
else ${echo} 'x - failed to create lock directory `'${lock_dir}\''.'
  exit 1
fi
# ============= MyData/lib/MyData.pm ==============
if test ! -d 'MyData'; then
  mkdir 'MyData'
if test $? -eq 0
then ${echo} 'x - created directory `MyData'\''.'
else ${echo} 'x - failed to create directory `MyData'\''.'
  exit 1
fi
fi
if test ! -d 'MyData/lib'; then
  mkdir 'MyData/lib'
if test $? -eq 0
then ${echo} 'x - created directory `MyData/lib'\''.'
else ${echo} 'x - failed to create directory `MyData/lib'\''.'
  exit 1
fi
fi
if test -f 'MyData/lib/MyData.pm' && test "$first_param" != -c; then
  ${echo} 'x -SKIPPING MyData/lib/MyData.pm (file already exists)'
else
${echo} 'x - extracting MyData/lib/MyData.pm (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'MyData/lib/MyData.pm' &&
package MyData;
X
use 5.008008;
use strict;
use warnings;
X
require Exporter;
X
our @ISA = qw(Exporter);
X
our @EXPORT = qw(
X	pack_buffer_t
X	unpack_buffer_t
);
X
our $VERSION = '0.01';
X
require XSLoader;
XXSLoader::load('MyData', $VERSION);
X
# Preloaded methods go here.
X
1;
__END__
SHAR_EOF
  (set 20 07 10 26 11 01 57 'MyData/lib/MyData.pm'; eval "$shar_touch") &&
  chmod 0644 'MyData/lib/MyData.pm'
if test $? -ne 0
then ${echo} 'restore of MyData/lib/MyData.pm failed'
fi
  if ${md5check}
  then (
       ${MD5SUM} -c >/dev/null 2>&1 || ${echo} 'MyData/lib/MyData.pm: MD5 check failed'
       ) << \SHAR_EOF
33237a8b0ca46928e94e098dede72c2e  MyData/lib/MyData.pm
SHAR_EOF
  else
test `LC_ALL=C wc -c < 'MyData/lib/MyData.pm'` -ne 277 && \
  ${echo} 'restoration warning:  size of MyData/lib/MyData.pm is not 277'
  fi
fi
# ============= MyData/Makefile.PL ==============
if test -f 'MyData/Makefile.PL' && test "$first_param" != -c; then
  ${echo} 'x -SKIPPING MyData/Makefile.PL (file already exists)'
else
${echo} 'x - extracting MyData/Makefile.PL (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'MyData/Makefile.PL' &&
use 5.008008;
use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
X    NAME              => 'MyData',
X    VERSION_FROM      => 'lib/MyData.pm', # finds $VERSION
X    PREREQ_PM         => {}, # e.g., Module::Name => 1.1
X    ($] >= 5.005 ?     ## Add these new keywords supported since 5.005
X      (ABSTRACT       => 'MyData',
X       AUTHOR         => 'Greg Bacon') : ()),
X    LIBS              => [''], # e.g., '-lm'
X    DEFINE            => '', # e.g., '-DHAVE_SOMETHING'
X    INC               => '-I.', # e.g., '-I. -I/usr/include/other'
X	# Un-comment this if you add C files to link with later:
X    # OBJECT            => '$(O_FILES)', # link all the C files too
);
SHAR_EOF
  (set 20 07 10 26 11 03 27 'MyData/Makefile.PL'; eval "$shar_touch") &&
  chmod 0644 'MyData/Makefile.PL'
if test $? -ne 0
then ${echo} 'restore of MyData/Makefile.PL failed'
fi
  if ${md5check}
  then (
       ${MD5SUM} -c >/dev/null 2>&1 || ${echo} 'MyData/Makefile.PL: MD5 check failed'
       ) << \SHAR_EOF
021dcf62e88c7b4494a8ad34da64ee1c  MyData/Makefile.PL
SHAR_EOF
  else
test `LC_ALL=C wc -c < 'MyData/Makefile.PL'` -ne 766 && \
  ${echo} 'restoration warning:  size of MyData/Makefile.PL is not 766'
  fi
fi
# ============= MyData/MANIFEST ==============
if test -f 'MyData/MANIFEST' && test "$first_param" != -c; then
  ${echo} 'x -SKIPPING MyData/MANIFEST (file already exists)'
else
${echo} 'x - extracting MyData/MANIFEST (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'MyData/MANIFEST' &&
Makefile.PL
MANIFEST
MyData.xs
t/MyData.t
lib/MyData.pm
SHAR_EOF
  (set 20 07 10 26 10 58 47 'MyData/MANIFEST'; eval "$shar_touch") &&
  chmod 0644 'MyData/MANIFEST'
if test $? -ne 0
then ${echo} 'restore of MyData/MANIFEST failed'
fi
  if ${md5check}
  then (
       ${MD5SUM} -c >/dev/null 2>&1 || ${echo} 'MyData/MANIFEST: MD5 check failed'
       ) << \SHAR_EOF
60844f8ab1b71186ccf41401781307b4  MyData/MANIFEST
SHAR_EOF
  else
test `LC_ALL=C wc -c < 'MyData/MANIFEST'` -ne 56 && \
  ${echo} 'restoration warning:  size of MyData/MANIFEST is not 56'
  fi
fi
# ============= MyData/MyData.xs ==============
if test -f 'MyData/MyData.xs' && test "$first_param" != -c; then
  ${echo} 'x -SKIPPING MyData/MyData.xs (file already exists)'
else
${echo} 'x - extracting MyData/MyData.xs (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'MyData/MyData.xs' &&
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
X
typedef struct buffer_t {
X  uint32_t a;
X  char b[16];
X  uint32_t c;
X  uint32_t d;
X  char e[6];
X  char f[8];
} buffer_t;
X
MODULE = MyData		PACKAGE = MyData		
X
SV *
pack_buffer_t(a, b, c, d, e, f)
X	U32  a
X	char *b
X	U32  c
X	U32  d
X	char *e
X	char *f
X  INIT:
X	buffer_t buf;
X  CODE:
X	buf.a = a;
X	Copy(b, buf.b, sizeof buf.b, char);
X        buf.c = c;
X        buf.d = d;
X	Copy(e, buf.e, sizeof buf.e, char);
X	Copy(f, buf.f, sizeof buf.f, char);
X	ST(0) = sv_2mortal(newSVpv((char *) &buf, sizeof buf));
X
void unpack_buffer_t(in)
X	SV *in
X  INIT:
X	buffer_t *p;
X        char     *sin;
X	STRLEN   len;
X  PPCODE:
X	p = (buffer_t *) SvPV(in, len);
X	XPUSHs(sv_2mortal(newSVuv(p->a)));
X	XPUSHs(sv_2mortal(newSVpv(p->b, sizeof(p->b))));
X	XPUSHs(sv_2mortal(newSVuv(p->c)));
X	XPUSHs(sv_2mortal(newSVuv(p->d)));
X	XPUSHs(sv_2mortal(newSVpv(p->e, sizeof(p->e))));
X	XPUSHs(sv_2mortal(newSVpv(p->f, sizeof(p->f))));
SHAR_EOF
  (set 20 07 10 26 11 01 26 'MyData/MyData.xs'; eval "$shar_touch") &&
  chmod 0644 'MyData/MyData.xs'
if test $? -ne 0
then ${echo} 'restore of MyData/MyData.xs failed'
fi
  if ${md5check}
  then (
       ${MD5SUM} -c >/dev/null 2>&1 || ${echo} 'MyData/MyData.xs: MD5 check failed'
       ) << \SHAR_EOF
5f51de590db2ddb456aa1d0bcf3b4433  MyData/MyData.xs
SHAR_EOF
  else
test `LC_ALL=C wc -c < 'MyData/MyData.xs'` -ne 947 && \
  ${echo} 'restoration warning:  size of MyData/MyData.xs is not 947'
  fi
fi
# ============= MyData/t/MyData.t ==============
if test ! -d 'MyData/t'; then
  mkdir 'MyData/t'
if test $? -eq 0
then ${echo} 'x - created directory `MyData/t'\''.'
else ${echo} 'x - failed to create directory `MyData/t'\''.'
  exit 1
fi
fi
if test -f 'MyData/t/MyData.t' && test "$first_param" != -c; then
  ${echo} 'x -SKIPPING MyData/t/MyData.t (file already exists)'
else
${echo} 'x - extracting MyData/t/MyData.t (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'MyData/t/MyData.t' &&
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl MyData.t'
X
#########################
X
use Test::More tests => 9;
BEGIN { use_ok('MyData') };
X
#########################
X
# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.
X
use constant {
X  A => 0xdeadbeef,
X  B => "0123456789abcdef",
X  C => 0xffffffff,
X  D => 0xa5a5a5a5,
X  E => "123456",
X  F => "   eight",
};
X
$buf = pack_buffer_t A, B, C, D, E, F;
ok(defined $buf, "defined result from pack_buffer_t");
X
@fields = unpack_buffer_t $buf;
is(scalar(@fields), 6, "fields from unpack_buffer_t");
X
($a,$b,$c,$d,$e,$f) = @fields;
X
ok($a == A, "unpacked a");
ok($b eq B, "unpacked b");
ok($c == C, "unpacked c: got " . sprintf("%08x", $c));
ok($d == D, "unpacked d: got " . sprintf("%08x", $d));
ok($e eq E, "unpacked e");
ok($f eq F, "unpacked f");
SHAR_EOF
  (set 20 07 10 26 10 47 31 'MyData/t/MyData.t'; eval "$shar_touch") &&
  chmod 0644 'MyData/t/MyData.t'
if test $? -ne 0
then ${echo} 'restore of MyData/t/MyData.t failed'
fi
  if ${md5check}
  then (
       ${MD5SUM} -c >/dev/null 2>&1 || ${echo} 'MyData/t/MyData.t: MD5 check failed'
       ) << \SHAR_EOF
e09c94b9215735e712662458c8a5f95d  MyData/t/MyData.t
SHAR_EOF
  else
test `LC_ALL=C wc -c < 'MyData/t/MyData.t'` -ne 977 && \
  ${echo} 'restoration warning:  size of MyData/t/MyData.t is not 977'
  fi
fi
if rm -fr ${lock_dir}
then ${echo} 'x - removed lock directory `'${lock_dir}\''.'
else ${echo} 'x - failed to remove lock directory `'${lock_dir}\''.'
  exit 1
fi
exit 0

-- 
Human ingenuity, not government, solves the problem of scarcity.  The
nations in which poverty is greatest are those that restrain human
ingenuity -- that is, freedom -- and punish initiative.
    -- Wendy McElroy


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

Date: Fri, 26 Oct 2007 10:37:05 -0700
From:  "jl_post@hotmail.com" <jl_post@hotmail.com>
Subject: Re: packing a C structure
Message-Id: <1193420225.191796.204490@19g2000hsx.googlegroups.com>

On Oct 25, 10:57 pm, haai...@gmail.com wrote:
> hi ,,,
>
> iam trying to pack a C structure to send via socket..i would like to
> know how to frame the template for the C structure..
>
> this is my structure
>
> typedef struct buffer_t {
>   uint32_t a;
>   char b[16];
>   uint32_t c;
>   uint32_t d;
>   char e[6];
>   char f[8];
>
> } buffer_t;
>
> kindly suggest me the format for the pack function call..this will
> help me to solve my issue...


Hi,

   I have the impression that what you want is to pack values in Perl
into a binary string of data that matches how a C program would do it.

   If I'm right, this might work:

      my $stringToSend = pack('I c16 I I c6 c8',
                              <YOUR PERL VARIABLES GO HERE>);

   However, it's quite likely that the C program packs the data in a
way so that they are properly byte-aligned.  If that's the case, the
above pack string may not work, and you'd probably have better luck
with the following pack string that inserts padding in the proper
places:

      my $stringToSend = pack('I c16 x![I] I I c6 c8 x![I]',
                              <YOUR PERL VARIABLES GO HERE>);

   Out of curiosity, when you declare b as a char array of 16 elements
is that because you're sending over 16 separate char values, or are
you sending one null-terminated string that can be a maximum of 15
characters long?

   If your intention is to use b[16] as a single string (holding a
maximum of 15 characters), you probably want to replace "c16" in the
above pack strings to "Z16" (you may also want to replace "c6" and
"c8" with "Z6" and "Z8").  That way, instead of sending over 33
separate variables (that is, three ints plus 30 characters), you'd be
sending over six separate variables (that is, three ints plus three
strings).

   So if it's the case that you want to send over three ints and three
strings, you might use code like this:

      my $a = 1;
      my $b = "Title of book";
      my $c = 3;
      my $d = 4;
      my $e = "March";
      my $f = "Sunday";
      my $stringToSend = pack('I Z16 x![I] I I Z6 Z8 x![I]',
                              $a, $b, $c, $d, $e, $f);

   Unfortunately, there's no real way to know what the proper pack
string should be unless you analyze the binary structure that your C
program writes out (or if can find one, reads in).  But it's likely
that one of pack strings I gave you (or a variant) will work.

   I hope this helps.  Perl's pack() function is very powerful and
useful when dealing with C structures written out to disk.

   -- Jean-Luc



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

Date: Fri, 26 Oct 2007 10:30:00 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: PID of exec
Message-Id: <472207f8$0$3566$815e3792@news.qwest.net>

hendedav@gmail.com wrote:

>>>   open STDOUT, '>', '/dev/null';
>>>   open STDIN, '>', '/dev/null';
>>>   open STDERR, '>', '/dev/null';

> Thanks Gary.  Is the STDERR pointed the correct way?  

Well, does the program possibly read or does it
possibly write?  You should know the difference
between '<', and '>', long before you ever use
fork(), IMHO.


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

Date: 26 Oct 2007 16:29:38 GMT
From: xhoster@gmail.com
Subject: Re: PID of exec
Message-Id: <20071026122940.051$G7@newsreader.com>

hendedav@gmail.com wrote:

> Also, this
> script seems to be generating zombies.  Anyone have ideas on how to
> clear that up?

You could double-fork.

> I was hoping that the "local $SIG{CHLD} = "IGNORE";"
> line would do the trick (as it stated in the perldoc's), but I guess
> not.

What if the "local" expires before the child does?  Then IGNORE is no
longer in effect and you leave zombies.  Did the docs say to set $SIG{CHLD}
to IGNORE with local?  That seems like a manifestly bizarre thing to do.
The effects of $SIG{CHLD} are inherently global and pretending it can be
localized is going to get you no where fast.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.


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

Date: Fri, 26 Oct 2007 10:22:53 -0700
From:  hendedav@gmail.com
Subject: Re: PID of exec
Message-Id: <1193419373.121190.211760@v3g2000hsg.googlegroups.com>

On Oct 26, 11:30 am, "J. Gleixner" <glex_no-s...@qwest-spam-
no.invalid> wrote:
> hende...@gmail.com wrote:
> >>>   open STDOUT, '>', '/dev/null';
> >>>   open STDIN, '>', '/dev/null';
> >>>   open STDERR, '>', '/dev/null';
> > Thanks Gary.  Is the STDERR pointed the correct way?
>
> Well, does the program possibly read or does it
> possibly write?  You should know the difference
> between '<', and '>', long before you ever use
> fork(), IMHO.

Thanks for the reply J, but I was unfamiliar with the usage in perl.
Redirecting in bash uses the same arrow (eg 2>&1).  Plus, you run out
of arrows after STDIN and STDOUT, so I had no idea what to use for
STDERR.  So, I figured maybe they all used the same arrow.  Oh well...

Dave



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

Date: Fri, 26 Oct 2007 10:40:42 -0700
From:  hendedav@gmail.com
Subject: Re: PID of exec
Message-Id: <1193420442.673852.278850@o80g2000hse.googlegroups.com>

On Oct 26, 12:29 pm, xhos...@gmail.com wrote:
> hende...@gmail.com wrote:
> > Also, this
> > script seems to be generating zombies.  Anyone have ideas on how to
> > clear that up?
>
> You could double-fork.
>
> > I was hoping that the "local $SIG{CHLD} = "IGNORE";"
> > line would do the trick (as it stated in the perldoc's), but I guess
> > not.
>
> What if the "local" expires before the child does?  Then IGNORE is no
> longer in effect and you leave zombies.  Did the docs say to set $SIG{CHLD}
> to IGNORE with local?  That seems like a manifestly bizarre thing to do.
> The effects of $SIG{CHLD} are inherently global and pretending it can be
> localized is going to get you no where fast.
>
> Xho
>
> --
> --------------------http://NewsReader.Com/--------------------
> The costs of publication of this article were defrayed in part by the
> payment of page charges. This article must therefore be hereby marked
> advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
> this fact.


No I don't recall the doc's saying to use local, but while working
with another part of the project, I was searching for answers and come
upon that as a solution.  Anyhow, I removed the 'local' portion, but I
am still receiving zombies.  I will post the entire script now for
review:


#!/usr/bin/perl -w

use strict;
use CGI qw(:all);
use CGI::Carp qw(fatalsToBrowser);

if (defined param('runnow')) {
   if (defined (my $pid = fork)) {
      if ($pid) {
         $SIG{CHLD} = "IGNORE";
         print "Content-type: text/xml", "\n\n";
         print "<info pid=\"". $pid ."\" date=
\"".scalar(localtime)."\" />";
      } else {
         $|++;
         open STDOUT, '>', '/dev/null';
         open STDIN, '<', '/dev/null';
         open STDERR, '>', '/dev/null';
         $_ = param('runnow');
         exec("/tmp/test.sh");
         exit();
      }
   } else {
      print "Content-type: text/xml", "\n\n";
      print "<error>\n";
      print "<message>The script couldn't be started.</message>\n";
      print "</error>\n";
   }

} elsif (defined param('pollJob')) {
   my $pid = param('pollJob');
   my $retval = `ps h -p $pid 2>&1`;

   print "Content-type: text/plain", "\n\n";
   if ($retval eq "") {
      print "Restore job completed...";
   } else {
      open(REJ, "/tmp/rej$pid");
      chomp ($retval=<REJ>);
      close(REJ);
      if ($retval ne 'Processing select data...') {
         print "$retval";
      } else {
         my $dir = readlink "/tmp/rej$pid.data";
            $dir = "/mnt" . substr($dir, rindex($dir,"/"), -4);
         my $data = '';
         if (! open(FILES, "/tmp/rej$pid.data")) { exit 0; }
         while (<FILES>) {
            s/^\./$dir/;
            if (-e $_) {$data .= "$_<br />";} else {last;}
         }
         close(FILES);
         print $data;
      }
   }
}


The top if statement only gets executed once (to start a process which
is monitored by the pollJob section), then the pollJob gets called
between 2-3 seconds until the job is done.  This job is only running
for 30 seconds (because of the test.sh script), but I accumulate
several many zombies.  Any ideas?

Thanks
Dave



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

Date: Fri, 26 Oct 2007 17:53:02 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: PID of exec
Message-Id: <Xns99D58D3B5ADAasu1cornelledu@127.0.0.1>

hendedav@gmail.com wrote in news:1193419373.121190.211760
@v3g2000hsg.googlegroups.com:

> On Oct 26, 11:30 am, "J. Gleixner" <glex_no-s...@qwest-spam-
> no.invalid> wrote:
>> hende...@gmail.com wrote:
>> >>>   open STDOUT, '>', '/dev/null';
>> >>>   open STDIN, '>', '/dev/null';
>> >>>   open STDERR, '>', '/dev/null';
>> > Thanks Gary.  Is the STDERR pointed the correct way?
>>
>> Well, does the program possibly read or does it
>> possibly write?  You should know the difference
>> between '<', and '>', long before you ever use
>> fork(), IMHO.
> 
> Thanks for the reply J, but I was unfamiliar with the usage in perl.
> Redirecting in bash uses the same arrow (eg 2>&1).  Plus, you run out
> of arrows after STDIN and STDOUT, so I had no idea what to use for
> STDERR.  So, I figured maybe they all used the same arrow.  Oh well...

This is a WTF in so many ways.

1) 2 > &1 means redirect the stderr output to where stdout points.

2) The pointy edge of the angle bracket is the target. So:

open FILEHANDLE, '<', 'source'

means you want to use FILEHANDLE to read from 'source'. On the other 
hand,

open ANOTHERHANDLE, '>', 'target'

means you want to write to 'target' the output you send to 
ANOTHERHANDLE.

STDERR is an output stream just as STDOUT is. STDIN is an input stream. 
I would think the suffixes OUT and IN would give that away. Now, I 
think, it is common sense (I have not questioned this in the last 20 
years) that STDERR is the stream where you *output* error messages so, 
again, the pointy edge of the angle bracket points away from the STDERR 
and to the target of that stream.

"I was running out of arrows so I used the same one for all of them". 
This is not a grocery store: The logic of "they had run out of apples so 
I bought pears" cannot be applied.

I think I am scarred for life (again).

Sinan

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
clpmisc guidelines: <URL:http://www.augustmail.com/~tadmc/clpmisc.shtml>



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

Date: Fri, 26 Oct 2007 11:11:51 -0000
From:  harivasantha04@gmail.com
Subject: see the riboosomes pics and information
Message-Id: <1193397111.195915.184450@o38g2000hse.googlegroups.com>

see the riboosomes pics and information

http://riboo.blogspot.com/



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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 979
**************************************


home help back first fref pref prev next nref lref last post