From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Thu, 14 Sep 2006 04:51:44 +0400 From: Alexey Tourbin To: devel@lists.altlinux.org Message-ID: <20060914005144.GZ17693@localhost.localdomain> Mail-Followup-To: devel@lists.altlinux.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="pWT/WNRdoJORH3Bm" Content-Disposition: inline Subject: [devel] procps.git X-BeenThere: devel@lists.altlinux.org X-Mailman-Version: 2.1.7 Precedence: list Reply-To: ALT Devel discussion list List-Id: ALT Devel discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Sep 2006 00:51:45 -0000 Archived-At: List-Archive: List-Post: --pWT/WNRdoJORH3Bm Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: quoted-printable =E9 =DE=CF, =D1 =D3=C4=C5=CC=C1=CC =D0=C1=D4=DE =CB procps, =CB=D5=C4=C1 = =C5=C7=CF =D4=C5=D0=C5=D2=D8 =CB=CF=CD=CD=C9=D4=C9=D4=D8? =F7 /people/ldv/packages/procps.git =D0=C9=D3=C1=D4=D8 =CE=C5 =C4=C1=C0=D4,= =C1 =CB=D5=C4=C1 =D4=CF=C7=C4=C1? $ git-push --all git.alt:/people/ldv/packages/procps.git updating 'refs/heads/master' from 25366cd4b1691a887e135a58ab894dff6cbae560 to 64ef9663bc217c76ee80007a8cda189a3c7e6919 updating 'refs/heads/origin' from 0000000000000000000000000000000000000000 to 25366cd4b1691a887e135a58ab894dff6cbae560 Generating pack... Done counting 7 objects. Result has 4 objects. Deltifying 4 objects. 100% (4/4) done Total 4, written 4 (delta 3), reused 0 (delta 0) Unpacking 4 objects unable to create temporary sha1 filename ./objects/obj_aObEAo: Permission d= enied fatal: failed to write object unpack unpacker exited with error code ng refs/heads/master n/a (unpacker error) ng refs/heads/origin n/a (unpacker error) $ git-log -p --max-count=3D1 commit 64ef9663bc217c76ee80007a8cda189a3c7e6919 Author: Alexey Tourbin Date: Thu Sep 14 04:42:46 2006 +0400 Implement the following behaviour: =20 1) execute a program also when a key is pressed; 2) but if that key is 'q' then exit instead. =20 This makes watch look more like an interactive program. diff --git a/procps/watch.c b/procps/watch.c index 18ded5e..4abad74 100644 --- a/procps/watch.c +++ b/procps/watch.c @@ -20,6 +20,7 @@ #include #include #include #include +#include #include #include #include @@ -227,6 +228,7 @@ main(int argc, char *argv[]) nonl(); noecho(); cbreak(); + nodelay(stdscr, TRUE); =20 for (;;) { time_t t =3D time(NULL); @@ -236,6 +238,10 @@ main(int argc, char *argv[]) FILE *p; int x, y; int oldeolseen =3D 1; + int key; + + if ((key =3D getch()) =3D=3D 'q')=20 + do_exit(0); =20 if (screen_size_changed) { get_terminal_size(); @@ -314,7 +320,16 @@ main(int argc, char *argv[]) =20 first_screen =3D 0; refresh(); - usleep(interval * 1000000); + + /* wait until tiemout or until a key press */ + { + fd_set set; + int fd =3D fileno(stdin); + struct timeval timeout =3D { interval, 0 }; + FD_ZERO(&set); + FD_SET(fd, &set); + select(fd + 1, &set, NULL, NULL, &timeout); + } } =20 endwin(); $ --pWT/WNRdoJORH3Bm Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) iD8DBQFFCKegfBKgtDjnu0YRAhtLAKDOGUcPqy/8CakgZwLqSjoAwUr1nwCghN2E N7IxDfAOondoT5CvX9T3cck= =8rQK -----END PGP SIGNATURE----- --pWT/WNRdoJORH3Bm--