🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Thread en un script bash

#13216
From: TvX
Date: Fri, 09 Mar 2001 16:29
49 lines
2539 bytes
Hola,
>puedes llamar a la funci�n con & al final: 
>
>Ejemplo:
>---------------8<-------------
>#!/bin/sh
> 
>function thread (){
>        while true ; do
>                sleep 1;
>                echo "hola";
>        done
>}
> 
>thread & 
>sleep 5
>
>
>--------------------->8---------
>
>Este tiene un problema, que cuando el script principal
>finalice, sigue ejecut�ndose thread indefinidamente.
>Supongo que hay alguna manera de lanzarlo y que 
>muera cuando el padre (el script) termine.
Bien, ya lo he probado, el problema es que el sleep 5 come mucha cpu.
�alguna manera de hacer que consuma menos sin mover el 5?, es decir,
�alguna manera de hacer que ese scrit y todos sus hijos est�n muy
limitados en el uso de cpu?

Por lo de hacer que se mueran no problemo:

rdo=`pidof -x /nombre/del/programa`
kill $rdo

Y as�n se mueren todos unos detr�s de otros hasta que te quedas en el
shell. Por cierto, a m� se me abren 3 procesos... �no deber�an de ser 2?

Gracias mil y saludines


-- 
---------------------------------------------------------
    \|/ En breve: "La cocina de la Vir"...  _O)   __/\__
   (.~.)            #19043                  /\\   \    /
__oO(_)Oo__ ___    ____ ____  ___           \_V   /_/\_\
\__    ___/ \   \ /   / \   \/  / Intermautas del mundo,
  |    |     \   Y   /   \     /        �Unios!
  |____|       \___/     /__/\ \ <nospamrojo@iname.com>
------------------------------\/-------------------------
Technical Details
Message-ID: <slrn9ai16i.24n.tovaritx@su27.tovaritx.red>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!news.tele.dk!134.222.94.5!npeer.kpnqwest.net!news!su27.tovaritx.red!tovaritx
References: <slrn9aevu3.212.tovaritx@su27.tovaritx.red> <d33889.7vi.ln@asimovi.localdomain>

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: f86c8,6c1786098beee5a2
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2001-03-09 08:34:50 PST
From: tovaritx@tovaritx.red (TvX)
Newsgroups: es.comp.os.linux.programacion
Subject: Re: Thread en un script bash
Date: 9 Mar 2001 16:29:08 GMT
Organization: Red Tovaritx. Servicio de news.
Lines: 49
Message-ID: <slrn9ai16i.24n.tovaritx@su27.tovaritx.red>
References: <slrn9aevu3.212.tovaritx@su27.tovaritx.red> <d33889.7vi.ln@asimovi.localdomain>
Reply-To: nospamrojo@iname.com
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Complaints-To: news@su27.tovaritx.red
NNTP-Posting-Date: 9 Mar 2001 16:29:08 GMT
User-Agent: slrn/0.9.6.3 (Linux)
NNTP-Posting-Host: 212.73.36.199
X-Original-NNTP-Posting-Host: 212.73.36.199
X-Trace: 9 Mar 2001 17:34:46 +0100, 212.73.36.199
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!news.tele.dk!134.222.94.5!npeer.kpnqwest.net!news!su27.tovaritx.red!tovaritx