home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / os / coherent / 6920 < prev    next >
Encoding:
Text File  |  1993-01-24  |  1.9 KB  |  75 lines

  1. Path: sparky!uunet!olivea!mintaka.lcs.mit.edu!spdcc!merk!fcshome!fredex
  2. From: fredex@fcshome.UUCP (fred smith)
  3. Newsgroups: comp.os.coherent
  4. Subject: using coherent's stime() function
  5. Keywords: time stime coherent system root
  6. Message-ID: <93012311262@fcshome.UUCP>
  7. Date: 24 Jan 93 03:02:20 GMT
  8. Organization: What?!? Absolutely none!
  9. Lines: 64
  10.  
  11. I'm trying to use stime() to set the system time. Whenever I call
  12. it it does NOT change the time, and I get a -1 return, indicating
  13. an error. 
  14.  
  15. Here is the program:
  16.  
  17.     #include <stdio.h>
  18.     #include <time.h>
  19.  
  20.     main (argc, argv)
  21.         int argc;
  22.         char ** argv;
  23.         {
  24.         extern int errno;
  25.         time_t    now;
  26.  
  27.     /* get current time & print it */
  28.         time (&now);
  29.         printf ("%s", ctime (&now));
  30.  
  31.     /* increment time by specified amount */
  32.         now += atoi (argv[1]);
  33.         printf ("%s", ctime (&now));
  34.  
  35.     /* attempt to set system clock */
  36.         errno = 0;
  37.         printf ("stime returns %d\n", stime (&now));
  38.  
  39.     /* print errno, and new time */
  40.         printf ("errno = %d\n", errno);
  41.         time (&now);
  42.         printf ("%s", ctime (&now));
  43.         }
  44.  
  45. When run (as root) thusly:
  46.  
  47.     testprog 10
  48.  
  49. the following output ensues:
  50.  
  51.     Sat Jan 23 16:26:52 1993
  52.     Sat Jan 23 16:27:02 1993
  53.     stime returns -1
  54.     errno = 14
  55.     Sat Jan 23 16:26:52 1993
  56.  
  57. Note that after the call to stime that errno == 14. Looking in
  58. /usr/include/errno.h reveals:
  59.  
  60.     #define    EFAULT    14        /* Bad system call argument address */
  61.  
  62. Am I doing something wrong here, or is stime() broken in the 4.0.1
  63. distribution??
  64.  
  65. All (reasonable) advice is welcome. 
  66.  
  67. Fred
  68.  
  69. -------------------------------------------------------------------------------
  70.  .----   Fred Smith    /                Office: 508-663-2524|Home: 617-438-5471
  71. ( /__  ,__.   __   __ /  __   : /                  fredex%fcshome@merk.merk.com
  72.  /    /  /   /__) /  /  /__) .+'                   or uunet!merk!fcshome!fredex
  73. /    /  (__ (___ (__(_ (___ / :__   BIX: fredex    or    primerd!fcshome!fredex  
  74. -------------------------------------------------------------------------------
  75.