> 但し、起きる曜日と時間の組合せは一定しています。
> 例えば、火曜日の17時30分からから1645秒とかの録画予約は必ず上記現象が発
> 生しています。
> 
> 1. 何故sleepがうまくいかないことがあるのでしょうか?
 fwcontrol が動いている間、ものすごく忙しくなっていて、sleep の後の
pkill がなかなか実行されない、というような状態なのかもしれません。
録画中に top とか vmstat などで system の状態を確認してみてください。

他の時間帯でも、fwcontrol 実行中に、
date ; sleep 10 ; date
などを何回か実行してみると再現するかもしれません。

> 2. もうちょっと別の方法でfwcontrolをうまく止める手段はないでしょうか?
 setitimer の勉強がてら、fwcontrol に無理やり abort 機能を組み込んでみました。
/usr/src/usr.sbin/fwcontrol/ で以下の patch を適用してみてください。
動作は未確認なので、試してみてうまく動くかどうか教えてください。
usage にも書き加えてありますが、1645 秒後に停止させるには、

fwcontrol -a 1645 -R hoge.dv

などとして使います。 

============================ここから=======================================
--- fwcontrol.c.org     2009-01-06 10:00:22.000000000 +0900
+++ fwcontrol.c 2009-01-06 10:23:32.000000000 +0900
@@ -39,6 +39,7 @@
 
 #include <sys/param.h>
 #include <sys/malloc.h>
+#include <sys/time.h>
 #include <sys/types.h>
 #include <sys/sysctl.h>
 #include <sys/socket.h>
@@ -82,6 +83,7 @@
                "%s [-u bus_num] [-prt] [-c node] [-d node] [-o node] [-s 
node]\n"
                "\t  [-l file] [-g gap_count] [-f force_root ] [-b pri_req]\n"
                "\t  [-M mode] [-R filename] [-S filename] [-m EUI64 | 
hostname]\n"
+               "\t  [-a abort_time]\n"
                "\t-u: specify bus number\n"
                "\t-p: Display current PHY register settings\n"
                "\t-r: bus reset\n"
@@ -98,6 +100,7 @@
                "\t-R: Receive DV or MPEG TS stream\n"
                "\t-S: Send DV stream\n"
                "\t-m: set fwmem target\n"
+               "\t-a: set abort time in seconds\n"
                , getprogname() );
        fprintf(stderr, "\n");
 }
@@ -735,6 +738,7 @@
        const char *device_string = "/dev/fw";
        int fd = -1, ch, len=1024;
        int32_t current_board = 0;
+       struct itimerval itv;
  /*
   * If !command_set, then -u will display the nodes for the board.
   * This emulates the previous behavior when -u is passed by itself
@@ -749,6 +753,7 @@
  * Holders for which functions
  * to iterate through
  */
+       bool set_abort_time = false;
        bool display_board_only = false;
        bool display_crom = false;
        bool send_bus_reset = false;
@@ -758,6 +763,7 @@
        bool dump_topology = false;
        bool dump_phy_reg = false;
 
+       int32_t abort_time = -1;
        int32_t priority_budget = -1;
        int32_t set_root_node = -1;
        int32_t set_gap_count = -1;
@@ -788,8 +794,12 @@
        /*
        * Parse all command line options, then execute requested operations.
        */
-       while ((ch = getopt(argc, argv, "M:f:g:m:o:s:b:prtc:d:l:u:R:S:")) != 
-1) {
+       while ((ch = getopt(argc, argv, "M:f:g:m:o:s:b:prtc:d:l:u:R:S:a:")) != 
-1) {
                switch(ch) {
+               case 'a':
+                       abort_time = strtol(optarg, NULL, 0);
+                       set_abort_time = true;
+                       break;
                case 'b':
                        priority_budget = strtol(optarg, NULL, 0);
                        if (priority_budget < 0 || priority_budget > INT32_MAX)
@@ -945,6 +955,22 @@
                return 0;
        }
 
+        if (set_abort_time) {
+               itv.it_interval.tv_sec = abort_time;
+               itv.it_interval.tv_usec = 0;
+               itv.it_value.tv_sec = abort_time;
+               itv.it_value.tv_usec = 0;
+               if (setitimer(ITIMER_REAL, &itv, NULL) != 0) {
+                       perror("setitimer");
+                       return 0;
+               }
+       }
+#if 0
+       while(1) {
+               printf("This is a test.\n");
+       }
+#endif
+
        /*
        * If -u <bus_number> is passed, execute 
        * command for that card only.
============================ここまで=======================================

吉田 充@横浜チーム.情報基盤センター.理化学研究所 (mits...@riken.jp)

メールによる返信