From owner-freebsd-questions Sun Jun 24 14: 6:40 2001 Delivered-To: freebsd-questions@freebsd.org Received: from discus.nl.uu.net (discus.nl.uu.net [193.67.79.178]) by hub.freebsd.org (Postfix) with ESMTP id F2E5B37B406 for ; Sun, 24 Jun 2001 14:06:37 -0700 (PDT) (envelope-from arjan@jak.nl) Received: from 1Cust66.tnt41.rtm1.nl.uu.net ([213.117.0.66]:2260 "EHLO jak.nl") by discus.nl.uu.net with ESMTP id ; Sun, 24 Jun 2001 23:06:29 +0200 Message-ID: <3B365658.24824777@jak.nl> Date: Sun, 24 Jun 2001 23:06:32 +0200 From: Arjan Knepper Organization: JAK++ Software Development B.V. X-Mailer: Mozilla 4.76 [en] (WinNT; U) X-Accept-Language: en MIME-Version: 1.0 To: fybar Cc: freebsd-questions@freebsd.org Subject: Re: pause in c program References: <3B3637D6.ABDB4B0@powersurfr.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG fybar wrote: > I am a newbie programmer running FreeBSD 3.5.1 on my laptop, I have had > > more success with this version with pcmcia cards. Anyhoo, I am writing > a program that I want to have print out some lines at a certain tempo. > Is > there a function that will let me pause the program for a specified > amount of time? > > I tried sleep, but I got some errors during the compile. Is there a way > > to call UNIX commands from a c program? #include #include #include #include int main () { ... char cmd [ 256 ]; memset ( cmd, 0, 256 ); snprintf ( cmd, 255, "some shell command %s", "some parameters" ); system ( cmd ); // execute sh-shell fork && execve cmd ... sleep ( 1 ); // sleep for a second usleep ( 1000 ); // sleep for an other ssecond return ( 0 ); } read: # man system # man -a 3 sleep # man -a 3 usleep Make sure to link against the stdclib: gcc ... -lc > > > My compiler is gcc 2.7. > > -- > fybar@nospam.powersurfr.com > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-questions" in the body of the message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message