syslog 总是显示如下格式:即有“Bad file descriptor”。而程序正常运行。why?
Dec 9 16:37:26 ubuntu [cksettling][7700]: [cksettling][/home/acer/cksettling.log]#012:Bad file descriptor#012
经过仔细查找,发现和正常显示的语句的差别在于有没有 “\n”;
于是把\n加到每一句日志语句中,如 FLOG_MSG("[log] becomeDaemon ok.\n");
运行,检查syslog:
cat /var/log/syslog | grep cksettling
一切正常显示,再也没有“Bad file descriptor”出现了。
Dec 10 23:33:06 ubuntu [cksettling][25991]: [cksettling starting...]#012#012
Dec 10 23:33:06 ubuntu [cksettling][25991]: [log] becomeDaemon begin...#012#012
Dec 10 23:33:06 ubuntu [cksettling][25991]: [log] while parent#012#012
Dec 10 23:33:06 ubuntu [cksettling][25997]: [log] becomeDaemon begin...#012#012
Dec 10 23:33:06 ubuntu [cksettling][25997]: [log] while parent2.#012#012
Dec 10 23:33:06 ubuntu [cksettling][25998]: [log] becomeDaemon ok.#012#012
Dec 10 23:33:06 ubuntu [cksettling][25998]: [log]/home/acer/workspace/ck/Debug#012#012
Dec 10 23:33:06 ubuntu [cksettling][25998]: [log]/home/acer/workspace/ck/Debug/cksettling.log#012#012
Dec 10 23:33:06 ubuntu [cksettling][25998]: [log]cksettling started#012#012
Dec 10 23:33:06 ubuntu [cksettling][25998]: Read config file:#012#012
Dec 10 23:33:06 ubuntu [cksettling][25998]: [log]db_host_ip = 127.0.0.1#012#012
Dec 10 23:33:06 ubuntu [cksettling][25998]: [log]db_name = cking_ucenter#012#012
Dec 10 23:33:06 ubuntu [cksettling][25998]: [log]db_port = 3306#012#012
Dec 10 23:33:06 ubuntu [cksettling][25998]: [log]db_psw = 123#012#012
Dec 10 23:33:06 ubuntu [cksettling][25998]: [log]db_user = root#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: connect to database ok#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb][SELECT id,concede,analysis,winrate,loserate, hostscore,guestscore,ctime #011#011#011FROM cking_ucenter.game_footballotteries #011#011#011where passed=1 and ctime > UNIX_TIMESTAMP(SUBDATE( now(),20)) #011#011#011order by id DESC #011#011#011limit 1000;]#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=227,concede=0.000000,analsisy=受让平手,winrate=2.00,loserate=1.82,hostscore=1,guestscore=0#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=226,concede=0.750000,analsisy=半球/一球,winrate=1.82,loserate=2.00,hostscore=3,guestscore=0#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=224,concede=-0.500000,analsisy=受让半球,winrate=2.10,loserate=1.70,hostscore=1,guestscore=1#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=223,concede=0.500000,analsisy=半球,winrate=1.99,loserate=1.83,hostscore=1,guestscore=0#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=222,concede=0.750000,analsisy=半球/一球,winrate=1.92,loserate=1.94,hostscore=1,guestscore=2#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=221,concede=1.250000,analsisy=一球/球半,winrate=1.96,loserate=1.86,hostscore=2,guestscore=0#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=220,concede=0.500000,analsisy=半球,winrate=2.02,loserate=1.74,hostscore=2,guestscore=1#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=219,concede=0.750000,analsisy=半球/一球,winrate=1.78,loserate=1.98,hostscore=1,guestscore=1#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=218,concede=-0.250000,analsisy=受让平手/半球,winrate=1.92,loserate=1.90,hostscore=1,guestscore=2#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=217,concede=0.250000,analsisy=平手/半球,winrate=1.82,loserate=1.94,hostscore=1,guestscore=1#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=216,concede=0.250000,analsisy=平手/半球,winrate=1.80,loserate=2.00,hostscore=0,guestscore=3#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=215,concede=0.000000,analsisy=平手,winrate=1.80,loserate=1.96,hostscore=0,guestscore=4#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=214,concede=0.250000,analsisy=平手/半球,winrate=1.82,loserate=2.04,hostscore=3,guestscore=0#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=34,concede=0.000000,analsisy=半球,winrate=1.86,loserate=2.00,hostscore=3,guestscore=0#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=33,concede=0.000000,analsisy=平手/半球,winrate=2.00,loserate=1.82,hostscore=0,guestscore=1#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=32,concede=0.000000,analsisy=平手/半球,winrate=1.82,loserate=2.00,hostscore=1,guestscore=0#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=31,concede=0.000000,analsisy=平手/半球,winrate=2.06,loserate=1.76,hostscore=0,guestscore=0#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=29,concede=0.000000,analsisy=平手/半球,winrate=1.92,loserate=1.90,hostscore=2,guestscore=2#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=26,concede=0.000000,analsisy=平手/半球,winrate=1.86,loserate=1.96,hostscore=0,guestscore=0#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=25,concede=0.000000,analsisy=平手,winrate=1.82,loserate=2.00,hostscore=1,guestscore=1#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=24,concede=0.000000,analsisy=平手/半球,winrate=1.88,loserate=1.98,hostscore=0,guestscore=0#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=22,concede=0.000000,analsisy=一球,winrate=1.96,loserate=1.86,hostscore=2,guestscore=0#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=21,concede=0.000000,analsisy=半球/一球,winrate=1.97,loserate=1.85,hostscore=2,guestscore=0#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=19,concede=0.000000,analsisy=半球,winrate=1.89,loserate=1.97,hostscore=1,guestscore=0#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=18,concede=0.000000,analsisy=半球/一球,winrate=1.96,loserate=1.80,hostscore=1,guestscore=2#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=16,concede=0.000000,analsisy=半球,winrate=2.05,loserate=1.81,hostscore=1,guestscore=3#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=15,concede=0.000000,analsisy=半球,winrate=2.02,loserate=1.80,hostscore=1,guestscore=3#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=14,concede=0.000000,analsisy=受让,winrate=1.92,loserate=1.90,hostscore=1,guestscore=0#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=12,concede=0.000000,analsisy=平手/半球,winrate=1.86,loserate=1.96,hostscore=0,guestscore=0#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=11,concede=0.000000,analsisy=半球,winrate=1.96,loserate=1.86,hostscore=2,guestscore=3#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=10,concede=0.000000,analsisy=球半/两球,winrate=2.02,loserate=1.74,hostscore=4,guestscore=0#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=9,concede=0.000000,analsisy=两球半,winrate=1.98,loserate=1.88,hostscore=1,guestscore=1#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=8,concede=0.000000,analsisy=半球,winrate=1.97,loserate=1.85,hostscore=1,guestscore=1#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=7,concede=0.000000,analsisy=受让,winrate=1.92,loserate=1.90,hostscore=1,guestscore=1#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=6,concede=0.000000,analsisy=受让,winrate=1.84,loserate=2.02,hostscore=3,guestscore=1#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=5,concede=0.000000,analsisy=受让,winrate=2.22,loserate=1.60,hostscore=2,guestscore=0#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=3,concede=0.500000,analsisy=测试数据11333,winrate=2.10,loserate=1.60,hostscore=2,guestscore=1#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]mysql[SELECT id,fk_user_id,fk_playorderid,val,multiple,amount ,UNIX_TIMESTAMP(`timestamp`) as ctime #011#011#011#011 FROM cking_ucenter.user_cathectic #011#011#011#011 WHERE resultval=0 order by id limit 1000;]#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=1,orderid=1,val=1,multiple=10,amount=2000#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=2,orderid=2,val=1,multiple=5,amount=500#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=13,orderid=2,val=2,multiple=1,amount=100#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=14,orderid=2,val=2,multiple=3,amount=300#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=20,orderid=37,val=2,multiple=1,amount=100#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=24,orderid=2,val=2,multiple=1,amount=100#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=28,orderid=213,val=1,multiple=1,amount=100#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=29,orderid=213,val=1,multiple=1,amount=100#012#012
Dec 10 23:33:07 ubuntu [cksettling][25998]: [log][loaddb]id=30,orderid=213,val=3,multiple=3,amount=300#012#012
Dec 10 23:33:37 ubuntu [cksettling][25998]: [log][loaddb][SELECT id,concede,analysis,winrate,loserate, hostscore,guestscore,ctime #011#011#011FROM cking_ucenter.game_footballotteries #011#011#011where passed=1 and ctime > UNIX_TIMESTAMP(SUBDATE( now(),20)) #011#011#011order by id DESC #011#011#011limit 1000;]#012#012
Dec 10 23:33:37 ubuntu [cksettling][25998]: [log][loaddb]mysql[SELECT id,fk_user_id,fk_playorderid,val,multiple,amount ,UNIX_TIMESTAMP(`timestamp`) as ctime #011#011#011#011 FROM cking_ucenter.user_cathectic #011#011#011#011 WHERE resultval=0 order by id limit 1000;]#012#012
Dec 10 23:33:37 ubuntu [cksettling][25998]: [log][loaddb]id=1,orderid=1,val=1,multiple=10,amount=2000#012#012
Dec 10 23:33:37 ubuntu [cksettling][25998]: [log][loaddb]id=2,orderid=2,val=1,multiple=5,amount=500#012#012
Dec 10 23:33:37 ubuntu [cksettling][25998]: [log][loaddb]id=13,orderid=2,val=2,multiple=1,amount=100#012#012
Dec 10 23:33:37 ubuntu [cksettling][25998]: [log][loaddb]id=14,orderid=2,val=2,multiple=3,amount=300#012#012
Dec 10 23:33:37 ubuntu [cksettling][25998]: [log][loaddb]id=20,orderid=37,val=2,multiple=1,amount=100#012#012
Dec 10 23:33:37 ubuntu [cksettling][25998]: [log][loaddb]id=24,orderid=2,val=2,multiple=1,amount=100#012#012
Dec 10 23:33:37 ubuntu [cksettling][25998]: [log][loaddb]id=28,orderid=213,val=1,multiple=1,amount=100#012#012
Dec 10 23:33:37 ubuntu [cksettling][25998]: [log][loaddb]id=29,orderid=213,val=1,multiple=1,amount=100#012#012
Dec 10 23:33:37 ubuntu [cksettling][25998]: [log][loaddb]id=30,orderid=213,val=3,multiple=3,amount=300#012#012
Dec 10 23:33:40 ubuntu [cksettling][25998]: cksettlingd get SIGTERM#012#012
Dec 10 23:33:40 ubuntu [cksettling][25998]: [log]ended.#012#012
Dec 10 23:33:40 ubuntu [cksettling][25998]: [SQL]mysql close connect.#012#012
Dec 10 23:33:40 ubuntu [cksettling][25998]: [cksetting]dbdo release for restart.#012#012
Dec 10 23:33:40 ubuntu [cksettling][25998]: [exit]~dbdo() #012#012