2011-01-21 09:59 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)

+ contrib/hbposix/tests/testdmn.prg
  * contrib/hbposix/hbposix.hbp
  + contrib/hbposix/daemon.c
    + Added HB_POSIX_DAEMON( lNoChdir, lNoClose ) --> lResult

  * contrib/hbmxml/hbmxmlp.prg
  * contrib/hbmagic/hbmagis.prg
  * contrib/hbmagic/tests/hbmagit.prg
  * contrib/hbmagic/hbmagic.c
    ! Minor fix to copyright line.

  ; Patch from Tamas. Thank you!

  * contrib/hbposix/tests/testdmn.prg
  * contrib/hbposix/daemon.c
    * Renamed POSIX_DAEMON() to HB_POSIX_DAEMON() to reflect 
      fact that it implement higher level posix functionality 
      (as opposed to being a direct wrapper to posix function 
      names 'deamon()')
This commit is contained in:
Viktor Szakats
2011-01-21 09:00:49 +00:00
parent 7263e28508
commit d43bb8058f
8 changed files with 147 additions and 4 deletions

View File

@@ -16,6 +16,27 @@
The license applies to all entries newer than 2009-04-28.
*/
2011-01-21 09:59 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
+ contrib/hbposix/tests/testdmn.prg
* contrib/hbposix/hbposix.hbp
+ contrib/hbposix/daemon.c
+ Added HB_POSIX_DAEMON( lNoChdir, lNoClose ) --> lResult
* contrib/hbmxml/hbmxmlp.prg
* contrib/hbmagic/hbmagis.prg
* contrib/hbmagic/tests/hbmagit.prg
* contrib/hbmagic/hbmagic.c
! Minor fix to copyright line.
; Patch from Tamas. Thank you!
* contrib/hbposix/tests/testdmn.prg
* contrib/hbposix/daemon.c
* Renamed POSIX_DAEMON() to HB_POSIX_DAEMON() to reflect
fact that it implement higher level posix functionality
(as opposed to being a direct wrapper to posix function
names 'deamon()')
2011-01-21 07:04 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/contrib/hbmxml/hbmxml.c
% optimization - moved hb_itemNew()/hb_itemRelease() outside for()

View File

@@ -6,7 +6,7 @@
* Harbour Project source code:
* libmagic wrapper functions
*
* Copyright 2010. Tamas TEVESZ <ice@extreme.hu>
* Copyright 2010 Tamas TEVESZ <ice@extreme.hu>
* www - http://harbour-project.org
*
* This program is free software; you can redistribute it and/or modify

View File

@@ -6,7 +6,7 @@
* Harbour Project source code:
* libmagic convenience functions
*
* Copyright 2010. Tamas TEVESZ <ice@extreme.hu>
* Copyright 2010 Tamas TEVESZ <ice@extreme.hu>
* www - http://harbour-project.org
*
* This program is free software; you can redistribute it and/or modify

View File

@@ -6,7 +6,7 @@
* Harbour Project source code:
* hbmagic test suite
*
* Copyright 2010. Tamas TEVESZ <ice@extreme.hu>
* Copyright 2010 Tamas TEVESZ <ice@extreme.hu>
* www - http://harbour-project.org
*
* This program is free software; you can redistribute it and/or modify

View File

@@ -6,7 +6,7 @@
* Harbour Project source code:
* MINIXML functions wrapper
*
* Copyright 2010. Tamas TEVESZ <ice@extreme.hu>
* Copyright 2010 Tamas TEVESZ <ice@extreme.hu>
* www - http://harbour-project.org
*
* This program is free software; you can redistribute it and/or modify

View File

@@ -0,0 +1,79 @@
/*
* $Id$
*/
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
* Copyright (c) 2011 Tamas TEVESZ <ice@extreme.hu>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "hbapi.h"
#include "hbvm.h"
#include <fcntl.h>
#include <unistd.h>
/*
* hb_posix_daemon( lNoChdir, lNoClose ) --> lResult
*/
HB_FUNC( HB_POSIX_DAEMON )
{
int fd;
switch( fork() )
{
case -1:
hb_retl( HB_FALSE );
return;
case 0:
break;
default:
hb_vmRequestQuit();
exit( 0 );
}
if( setsid() == -1 )
{
hb_retl( HB_FALSE );
return;
}
if( ! hb_parl( 1 ) )
( void ) chdir( "/" );
if( ! hb_parl( 2 ) && ( fd = open( "/dev/null", O_RDWR ) ) != -1 )
{
( void ) dup2( fd, STDIN_FILENO );
( void ) dup2( fd, STDOUT_FILENO );
( void ) dup2( fd, STDERR_FILENO );
if( fd > 2 )
( void ) close( fd );
}
hb_retl( HB_TRUE );
}

View File

@@ -12,3 +12,4 @@
-stop{!unix}
hbposix.c
daemon.c

View File

@@ -0,0 +1,42 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
*
* Copyright 2011 Tamas TEVESZ <ice@extreme.hu>
* www - http://harbour-project.org
*
*/
REQUEST HB_GT_CGI_DEFAULT
PROCEDURE Main()
LOCAL cLogFile, cLogText
cLogFile := hb_ps() + CurDir() + hb_ps() + "testdmn.txt"
OutStd( hb_strFormat( "Parent(%d) launching child... ", posix_getpid() ) + hb_eol() )
IF ! hb_posix_daemon( .F., .F. )
OutStd( "failed." + hb_eol() )
ErrorLevel( 1 )
QUIT
ENDIF
IF File( cLogFile )
FErase( cLogFile )
ENDIF
OutStd( "***" + hb_eol() + "* If you see this, something is b0rked" + hb_eol() + "***" + hb_eol() )
cLogText := hb_strFormat( "Hello, this is the daemon child(%d) writing.", posix_getpid() ) + hb_eol()
cLogText += hb_strFormat( "I am currenty residing in %s and ", hb_ps() + CurDir() ) + hb_eol()
cLogText += hb_strFormat( "am writing this message to %s", cLogFile ) + hb_eol()
cLogText += "Good bye now." + hb_eol()
hb_MemoWrit( cLogFile, cLogText )
RETURN