9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] wctl
@ 2023-05-09  3:31 有澤健治
  2023-05-09  6:11 ` umbraticus
  0 siblings, 1 reply; 6+ messages in thread
From: 有澤健治 @ 2023-05-09  3:31 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 1307 bytes --]

Hello, 9fans

In writing a program I met a problem on finding window size.
cat /dev/wctl
shows something like this:
hebe% cat /dev/wctl
        456          91        1214         603     current     visible
hebe%
Need DEL key to stop. I want to get this info without manual intervention.

I tried a experimental code:

#include <u.h>
#include <libc.h>

void
main(void)
{ char buf[256];
int fd,n;
fd = open("/dev/wctl",OREAD);
print("%d\n",fd);
//n = readn(fd,buf,1);//NG. buffer too small
//n = readn(fd,buf,48);//NG. truncated
//n = readn(fd,buf,56);//NG. truncated
//n = readn(fd,buf,70);//NG. truncated
n = readn(fd,buf,71);//OK, n=71
//n = readn(fd,buf,111);//OK.  n=71
//n = readn(fd,buf,117);//OK.  n=71
//n = readn(fd,buf,128);//NG. hungup
/* I donn't know the reasnalbe value m for readn(fd,buf,m) */
if(n < 0){
print("%r\n");
}
buf[n] = 0;
print("n=%d\n%s\n",n,buf);
close(fd);
exits(nil);
}

I don't know whether m in readn(fd,buf,m) depends on something or not.
If depends. then how to know getting OK value?

Kenji Arisawa

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tf13f657beb7b12c0-M60ccbc9ae01219d2e2f46c4f
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

[-- Attachment #2: Type: text/html, Size: 2141 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-05-09 21:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-09  3:31 [9fans] wctl 有澤健治
2023-05-09  6:11 ` umbraticus
2023-05-09  7:59   ` Richard Miller
2023-05-09 13:01     ` 有澤健治
2023-05-09 15:04       ` sirjofri
2023-05-09 21:17         ` 有澤健治

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).