*BSD News Article 92499


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!news.ecn.uoknor.edu!feed1.news.erols.com!news-xfer.netaxs.com!news.mathworks.com!news-peer.gsl.net!cyclic.gsl.net!news.gsl.net!news-paris.gsl.net!news.gsl.net!news.kolumbus.fi!news.csc.fi!nokia.fi!ntc.nokia.com!tnso09.tele.nokia.fi!jkokko
From: Jari Kokko <nobody@nowhere.net>
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Bug with times(2) on FreeBSD 2.2R?
Date: 1 Apr 1997 08:30:55 GMT
Organization: Älytön Wööppäri
Lines: 49
Message-ID: <5hqh3v$3ga@axl02it.ntc.nokia.com>
NNTP-Posting-Host: tnso09.ntc.nokia.com
X-email-spoofing-reason: To avoid spamming automagic email grabbers
Originator: jkokko@tnso09.tele.nokia.fi
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.freebsd.misc:38196


Under FreeBSd 2.2-R, why does this program output

apeli ~ $ ./timestst 
0, 396, 0, 0

meaning that only system time is used? I noticed this behaviour first
with dhrystone which says

Dhrystone(1.1) time for 500000 passes = 0
zsh: floating point exception (core dumped)  ./d

#include <stdio.h>
#include <stdlib.h>
#include <sys/times.h>

main()
{
    extern int errno;
    unsigned long int i=0;
    struct tms t;
    FILE *f;

    while (i++ < 1000) {
        f=fopen("foo", "w");
        if (!f)
            perror("dghj");
        fclose(f);
    }
        

    errno=0;
    if ((i=times(&t)) < 0)
        perror("foo");
    

    printf("%d, %d, %d, %d\n", 
           t.tms_utime,
           t.tms_stime,
           t.tms_cutime,
           t.tms_cstime);
    
    
    return 0;
}

/* Jari Kokko */
-- 
I never drink water, fish function in it.