home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!mintaka.lcs.mit.edu!spdcc!merk!fcshome!fredex
- From: fredex@fcshome.UUCP (fred smith)
- Newsgroups: comp.os.coherent
- Subject: using coherent's stime() function
- Keywords: time stime coherent system root
- Message-ID: <93012311262@fcshome.UUCP>
- Date: 24 Jan 93 03:02:20 GMT
- Organization: What?!? Absolutely none!
- Lines: 64
-
- I'm trying to use stime() to set the system time. Whenever I call
- it it does NOT change the time, and I get a -1 return, indicating
- an error.
-
- Here is the program:
-
- #include <stdio.h>
- #include <time.h>
-
- main (argc, argv)
- int argc;
- char ** argv;
- {
- extern int errno;
- time_t now;
-
- /* get current time & print it */
- time (&now);
- printf ("%s", ctime (&now));
-
- /* increment time by specified amount */
- now += atoi (argv[1]);
- printf ("%s", ctime (&now));
-
- /* attempt to set system clock */
- errno = 0;
- printf ("stime returns %d\n", stime (&now));
-
- /* print errno, and new time */
- printf ("errno = %d\n", errno);
- time (&now);
- printf ("%s", ctime (&now));
- }
-
- When run (as root) thusly:
-
- testprog 10
-
- the following output ensues:
-
- Sat Jan 23 16:26:52 1993
- Sat Jan 23 16:27:02 1993
- stime returns -1
- errno = 14
- Sat Jan 23 16:26:52 1993
-
- Note that after the call to stime that errno == 14. Looking in
- /usr/include/errno.h reveals:
-
- #define EFAULT 14 /* Bad system call argument address */
-
- Am I doing something wrong here, or is stime() broken in the 4.0.1
- distribution??
-
- All (reasonable) advice is welcome.
-
- Fred
-
- -------------------------------------------------------------------------------
- .---- Fred Smith / Office: 508-663-2524|Home: 617-438-5471
- ( /__ ,__. __ __ / __ : / fredex%fcshome@merk.merk.com
- / / / /__) / / /__) .+' or uunet!merk!fcshome!fredex
- / / (__ (___ (__(_ (___ / :__ BIX: fredex or primerd!fcshome!fredex
- -------------------------------------------------------------------------------
-