From owner-freebsd-questions@FreeBSD.ORG Mon Mar 2 21:25:39 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 837641065673 for ; Mon, 2 Mar 2009 21:25:39 +0000 (UTC) (envelope-from cpghost@cordula.ws) Received: from fw.farid-hajji.net (fw.farid-hajji.net [213.146.115.42]) by mx1.freebsd.org (Postfix) with ESMTP id 1A9C98FC15 for ; Mon, 2 Mar 2009 21:25:38 +0000 (UTC) (envelope-from cpghost@cordula.ws) Received: from phenom.cordula.ws (phenom [192.168.254.60]) by fw.farid-hajji.net (Postfix) with ESMTP id 12699336A2; Mon, 2 Mar 2009 22:25:36 +0100 (CET) Date: Mon, 2 Mar 2009 22:25:39 +0100 From: cpghost To: lacalling Message-ID: <20090302212539.GA46243@phenom.cordula.ws> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) Cc: freebsd-questions@freebsd.org Subject: Re: How to repeat playing mp3 with mpg123 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Mar 2009 21:25:39 -0000 On Mon, Mar 02, 2009 at 10:55:29PM +0800, lacalling wrote: > Since mpg123 does not support repeat model, i tried to write a script to > play mp3 repeatedly. > > I tried bash like this > for((;;)) > do > mpg123 [mp3] & > done > but it keeps running new mpg123 in background . You asked for it to run in the background (with '&'). In fact, you're spawning many mpg123 processes here... > but mpg123 [mp3] in foreground cant be terminated by control C Not too familiar with mpg123 (I'm using mplayer), but in such close loops, Ctrl-C usually works, but not as intended: it stops one mpg123 process (unless mpg123 sets its signal mask in such a way as to block or ignore SIGINT?), but the next one resumes almost immediately thereafter. To Ctrl-C the loop itself is not easy, because the time slice between the end of one mpg123 process and the start of the next one (when the shell is in the foreground) is pretty tiny. Try adding a 'sleep 1' or something like that after mpg123, and it will be easier. > Could anyone provide more ideas. > thank you. -cpghost. -- Cordula's Web. http://www.cordula.ws/