Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2000-09

Problem with daemon.pp

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Nylund Sakari

Hello !

I'm new on this list and perhaps have missed info what I'm looking for... forgive me . I upgraded to latest fpc (1.0). I think I had previously something 0.99-?(abt year old or so).

Then I returned to daemon.pp that is introduced on UNITS section of
fpc-homepages. Previously I managed to compile daemon.pp and also made
some programs of my own using this source as base. Now I found out that I
cant use (compile) them any more with new version of fpc.  First problem
in daemon.pp was:
  new(aHup);
  new(aTerm);
    aTerm^.sa_handler := @DoSig;  <-------------here
    aTerm^.sa_mask := 0;
    aTerm^.sa_flags := 0;
    aTerm^.sa_restorer := nil;
    aHup^.sa_handler := @DoSig;  <-------------and here
    aHup^.sa_mask := 0;

After some thinking and manual reading :-O I replaced "aTerm^.sa_handler" as "aTerm^.handler.sh" and passed all without erros in compile.

How ever, running program will not work. It gives runtime error 2. I have pinpointed erro to:

  Case pid of
       0 : Begin { we are in the child }
          Close(input);  { close standard in }
          Close(output); { close standard out }
          Assign(output,'/dev/null');
          ReWrite(output);  <--------- HERE
          Close(stderr); { close standard error }
          Assign(stderr,'/dev/null');
          ReWrite(stderr);  <----------AND HERE
 Now I just do not have any more ideas !
 I tested also with: program test; uses Linux; var ofile : text;  Begin
       Assign ofile,´/dev/null');
       rewrite(ofile);
       close(ofile);
 end.

Compiles OK, but ends also to runtime error 2 !

Any ideas ? Something has changed between fpc versions but I can not dig it
out from manuals or homepage ! (I guess it's there, I just can't see it ;-( )

Please help !
Saku

Ken J. Wright
to Nylund Sakari
you wrote 22 lines
Hello ! I'm new on this list and perhaps have missed info what I'm looking for... forgive me . I upgraded to latest fpc (1.0). I think I had previously something 0.99-?(abt year old or so). Then I returned to daemon.pp that is introduced on UNITS section of fpc-homepages. Previously I managed to compile daemon.pp and also made some programs of my own using this source as base. Now I found out that I cant use (compile) them any more with new version of fpc. First problem in daemon.pp was: new(aHup); new(aTerm); aTerm^.sa_handler := @DoSig; <-------------here aTerm^.sa_mask := 0; aTerm^.sa_flags := 0; aTerm^.sa_restorer := nil; aHup^.sa_handler := @DoSig; <-------------and here aHup^.sa_mask := 0; After some thinking and manual reading :-O I replaced "aTerm^.sa_handler" as "aTerm^.handler.sh" and passed all without erros in compile.

sa_handler is correct. Unfortunately 1.00 had an error in the linux unit. You will need to download a snapshot to fix this problem.

Ken

Ken J. Wright
to Ken J. Wright
Show quoted text 12 lines
sa_handler is correct. Unfortunately 1.00 had an error in the linux unit. You will need to download a snapshot to fix this problem. Case pid of 0 : Begin { we are in the child } Close(input); { close standard in } Close(output); { close standard out } Assign(output,'/dev/null'); ReWrite(output); <--------- HERE Close(stderr); { close standard error } Assign(stderr,'/dev/null'); ReWrite(stderr); <----------AND HERE

I was a bit mistaken in my first reply. Here's the original bug report.

***************************************************************************

Show quoted text 9 lines
>On Thu, 13 Jul 2000, Mike Ravkin wrote: > It seems that with v1.0, when you attempt to reset() or rewrite() a text file > that's pointed to /dev/null, you get a RTE#2 (File not Found?) > The src/fpc-1.0/demos/linux/daemon.pp code doesn't work because of this. Someone applied a WRONG patch to the system unit. First bugs of 1.0 :( Michael.

*********************************************************************************

Ken