關於列印過程中強制移除印表機的處理

2021-06-22 05:06:44 字數 2756 閱讀 3935

在列印過程中,強制拔除印表機會出現如下狀況:

hpijs會輸出這個資訊:

unable to send devicestatus: bad file descriptor: hplip_api.c 641

一直迴圈。

查得$ man errno | grep "bad file descriptor"

ebadf           bad file descriptor (posix.1)

解決方案1:

目前改善的是獲取hpijs

的pid

,將其kill 9

之後可以結束不停的列印。但是也會列印幾百行後停止,所以優化的時候也要將

hpijs

中這句列印去掉。

static int print_stop_print(struct print_device_t* dev) 

解決方案2

:(最終採用的方案)

當出現這種情況的時候將自己kill

掉。輸出一次資訊,然後將自己

kill掉。

if(errno == ebadf)

exit(-1); // kill(getpid(), 9);

1.exit(-1);

測試結果:

gpl ghostscript 9.04 (2011-08-05)

this software comes with no warranty: see the file public for details.

processing pages 1 through 1.

page 1

unable to write to output, fd=6, count=4096: input/output error

unable to write to output, fd=6, count=4096: no such device

unable to write to output, fd=6, count=4096: no such device

unable to write to output, fd=6, count=4096: no such device

unable to write to output, fd=6, count=4096: no such device

unable to send devicestatus: bad file descriptor: hplip_api.c 642

error: /ioerror in --showpage--

operand stack:

1   true

execution stack:

%interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1910   1   3   %oparray_pop   1909   1   3   %oparray_pop   1893   1   3   %oparray_pop   --nostringval--   --nostringval--   2   1   1   --nostringval--   %for_pos_int_continue   --nostringval--   --nostringval--   1793   0   9   %oparray_pop   --nostringval--   --nostringval--

dictionary stack:

--dict:1161/1684(ro)(g)--   --dict:1/20(g)--   --dict:82/200(l)--   --dict:82/200(l)--   --dict:108/127(ro)(g)--   --dict:291/300(ro)(g)--   --dict:23/30(l)--   --dict:6/8(l)--   --dict:22/40(l)--

current allocation mode is local

last os error: 32

gpl ghostscript 9.04: unrecoverable error, exit code 1

測試成功,在輸出一行

unable to send devicestatus: bad file descriptor: hplip_api.c 642後,直接hpijs斃命。

2.kill(getpid(), 9)的測試結果

測試為無效。

sed命令:

1).新增

#include 

sed -i '38s/#include "hplip_api.h"/#include \n#include "hplip_api.h"/' hplip_api.c

2.)新增

if(errno == ebadf)

exit(exit_failure);

sed -i '643s/goto mordor;/if(errno == ebadf)\n            exit(-1);\n        goto mordor;\n/' hplip_api.c

擴充套件:hpijs是乙個服務,可以在像

vold

或者其它一樣啟動和停止。這樣就更符合

android

精神。

從登錄檔中刪除印表機列表中的印表機

刪除網路印表機 從登錄檔項中hkey current user printers connections 下找到要刪除的印表機項刪除即可 刪除本地印表機hkey local machine system currentcontrolset control print printers 下找到要刪除的...

關於Epson噴墨印表機的記錄

2 噴墨印表機,乙個過去被定義為家用應用的產品,越來越多的出現在各種應用中。這當然得益於噴墨列印技術的日新月異,為我們在列印辦公提供了更多的應用選擇。不過,噴墨印表機的 固有弊端 始終沒有得到很好的解決 噴頭堵塞。造成噴頭堵塞的原因很多,例如很久沒有列印,或者墨水雜質,或者噴頭磨損等等。這裡編輯整理...

關於印表機的一點記錄

2020年11月15日,帶著實驗室的惠普印表機去圓明園西路去維修。跟維修人員溝通了很多,目前市面上辦公型印表機 以a4紙型為主列印的 主要以雷射印表機和噴墨印表機為主。下面以 形式對這兩類印表機做乙個對比 雷射印表機 噴墨印表機 列印速度 較快較慢 列印色彩 大多數是黑白列印,彩色列印的機器很貴 大...