I want to handle a // printer correctly. Here’s the pseudo-code of the logic I follow for testing:
check the printer status
if printer ready
open device for writing
loop
check the printer status
if printer ready
write stuff to it
end loop
close device
endif
end
I use devctl(fd, DCMD_CHR_LINESTATUS, …) to check the printer status and fwrite() to write stuff to it.
The problem is that when looping, if the printer status changes (OFFLINE or PAPEROUT), fwrite() never returns(unless the printer comes ready again), giving me no chance to alert the user.
Any idea how to this right?
Thanks!