🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #12742

implementacion del comando interno time

#12742
From: Nacho Robledo
Date: Sun, 20 May 2001 16:55
37 lines
1987 bytes
Hola estoy creando un minishell como bash pero de un numero reducido, muy
reducido de comandos. Ahora estoy tratando de implementar el comando interno
time con la ayuda de la llamada al sistema times(). Sin embargo estoy
teniendo problemas porque quiero mostrar el tiempo real, usuario y cpu...e
intento ejecutar el comando en un proceso hijo. Alguien puede orientarme
sobre como hacerlo?

 struct tms tiempo1,tiempo2;
 long t1, t2;

times(&tiempo1);
pid_t pid;
pid = fork()
if  (pid == 0)
  {
     execlp("ls","ls",NULL);
     perror("execlp");
     exit(-1);
  }
while (pid != wait(NULL));

times(&tiempo2);

Esto es todo lo que he cosegudio sacar... Ahora los tiempos no consigo
convertirlos a segundos y muchos me dan 0 aunque cambie el ls por un cat de
un fichero largo.

Gracias y saludos

--
--
 Ignacio Robledo Rosell
 mailto:rrilpm@arrakis.es
 http://zipi.fi.upm.es/~g990406
 ****************************************
 "When code matters more than comercials"
 ****************************************
Technical Details
Message-ID: <3b07f785$1_3@news.arrakis.es>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!dispose.news.demon.net!demon!btnet-peer0!btnet-peer!btnet!newsfeed.bt.es!195.5.65.34.MISMATCH!caladan.arrakis.es

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII-7-bit
X-Google-Thread: f86c8,e7f8d4911dea7959,start
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2001-05-20 10:02:02 PST
From: "Nacho Robledo" <rrilNOSPAMpm@arrakis.es>
Newsgroups: es.comp.os.linux.programacion
Subject:  implementacion del comando interno time
Date: Sun, 20 May 2001 18:55:24 +0200
Lines: 40
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4133.2400
X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
NNTP-Posting-Host: 212.59.223.175
Message-ID: <3b07f785$1_3@news.arrakis.es>
X-Trace: 20 May 2001 18:57:41 +0100, 212.59.223.175
Organization: Arrakis Servicios y Comunicaciones SLU
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!dispose.news.demon.net!demon!btnet-peer0!btnet-peer!btnet!newsfeed.bt.es!195.5.65.34.MISMATCH!caladan.arrakis.es