× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Since finding out that on v5r1 the NTP service does not update the system
clock function I decided to find a unix source for a SNTP client.  I found
one at http://www.hpcf.cam.ac.uk/export/ .  It all compiles just fine with
the exception of thne unix.c program.  I have included it here.  The 400
has no concept of a TTY devoce and I am not sure how to code.
If I can get over this small hurdle, I will make it available.

============================================

/*  Copyright (C) 1996 N.M. Maclaren
    Copyright (C) 1996 The University of Cambridge

This includes code that really should have been part of ANSI/ISO C, but was
left out for historical reasons (despite requests to define ftty), plus
the get_lock() function. */



#include "header.h"

#include <sys/types.h>
#include <unistd.h>
#include <signal.h>

#define UNIX
#include "kludges.h"
#undef UNIX

#ifndef LOCKFILE
    #define LOCKFILE "/etc/msntp.pid"          /* Stores the pid */
#endif

void do_nothing (int seconds) {

/* Wait for a fixed period, possibly uninterruptibly.  This should not wait
for less than the specified period, if that can be avoided. */

    sleep(seconds+3);          /* +2 is enough for POSIX */
}

/*  This is the section that needs to be changed for the 400  */

int ftty (FILE *file) {

/* Return whether the file is attached to an interactive device. */

    return isatty(fileno(file));
}

void set_lock (int lock) {

/* Check that we have enough privileges to reset the time and that no other
updating msntp process is running, but don't bother with fancy
interlocking.
This function is really only to permit the daemon mode to be restarted in a
cron job and improve the diagnostics; it can be replaced by a 'return'
statement if it causes implementation difficulties.  Note that there is
little
point in clearing the lock under Unix, but do so anyway. */

    FILE *file;
    long pid;

    if (LOCKFILE == NULL) return;
    if (lock) {
        errno = 0;
        if ((file = fopen(LOCKFILE,"r")) != NULL &&
                fscanf(file,"%ld",&pid) == 1 && kill(pid,0) == 0) {
            if (verbose || isatty(STDIN_FILENO) || isatty(STDOUT_FILENO))
                fatal(0,"another msntp process is currently running",NULL);
            else
                fatal(0,NULL,NULL);
        }
        if (file != NULL) fclose(file);
        errno = 0;
        if ((file = fopen(LOCKFILE,"w")) == NULL ||
                fprintf(file,"%ld\n",(long)getpid()) <= 0 ||
                ferror(file) || fclose(file) != 0)
            fatal(1,"unable to write PID to %s",LOCKFILE);
        adjust_time(0.0,0,0.0);
    } else {
        errno = 0;
        if (remove(LOCKFILE) != 0)
            fatal(1,"unable to remove the msntp lockfile %s",LOCKFILE);
    }
}


-------------------------
 Bryan Dietz
3X Corporation






As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.