From: 有澤健治 <karisawa@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: [9fans] wctl
Date: Tue, 9 May 2023 12:31:57 +0900 [thread overview]
Message-ID: <CAN4cm2sYXfT6FdVOtOiWP8oqMfzi+kWGQOuYW8Yao=R4m9EMww@mail.gmail.com> (raw)
[-- 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 --]
next reply other threads:[~2023-05-09 3:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-09 3:31 有澤健治 [this message]
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 ` 有澤健治
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAN4cm2sYXfT6FdVOtOiWP8oqMfzi+kWGQOuYW8Yao=R4m9EMww@mail.gmail.com' \
--to=karisawa@gmail.com \
--cc=9fans@9fans.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).