首页
\
问答
\
poll C Linux函数如何工作?(Why is this message not only displayed when a file is written to (using the poll C Linux function)?)
poll C Linux函数如何工作?(Why is this message not only displayed when a file is written to (using the poll C Linux function)?)
我在阅读C编程中的民意调查,并在poll(2)手册页中构建了一个应用程序。
这是一个例子:#include<stdio.h> #include <stropts.h> #include <poll.h> #include <fcntl.h> int main() { struct pollfd fds[2]; int timeout_msecs = -1; int ret; int i; /* Open STREAMS device. */ fds[0].fd = open("/home/jeshwanth/mywork/poll/dev0", O_RDONLY); fds[1].fd = open("/home/jeshwanth/mywork/poll/dev1", O_RDONLY); fds[0].events = POLLOUT | POLLWRBAND; fds[1].events = POLLOUT | POLLWRBAND; while (1) { ret = poll(fds, 2, timeout_msecs); if (ret > 0) { /* An event on one of the fds has occurred. */ for (i = 0; i < 2; i++) { if (fds[i].revents != 0) { /* Priority data may be written on device number i. */ printf( "Priority Data may be written on device number %d POLLWRBAND\n", i); } if (fds[i].revents = !0) { /* Data may be written on device number i. */ printf("Data may be written on device number %d POLLOUT\n", i); } if (fds[i].revents = !0) { /* A hangup has occurred on device number i. */ printf("A hangup has occurred on device number %d\n", i); } } } } return 0; }
注意:dev0和dev1是普通文件。 当我运行程序时,如果dev0和dev1中没有发生任何事件,则显示该消息。 但我期待一些写入文件发生时,只有它应该显示消息。 我错了吗?
I was reading about poll in C programming and built an application given on the poll(2) man page.
Here is the example:
#include<stdio.h> #include <stropts.h> #include <poll.h> #include <fcntl.h> int main() { struct pollfd fds[2]; int timeout_msecs = -1; int ret; int i; /* Open STREAMS device. */ fds[0].fd = open("/home/jeshwanth/mywork/poll/dev0", O_RDONLY); fds[1].fd = open("/home/jeshwanth/mywork/poll/dev1", O_RDONLY); fds[0].events = POLLOUT | POLLWRBAND; fds[1].events = POLLOUT | POLLWRBAND; while (1) { ret = poll(fds, 2, timeout_msecs); if (ret > 0) { /* An event on one of the fds has occurred. */ for (i = 0; i < 2; i++) { if (fds[i].revents != 0) { /* Priority data may be written on device number i. */ printf( "Priority Data may be written on device number %d POLLWRBAND\n", i); } if (fds[i].revents = !0) { /* Data may be written on device number i. */ printf("Data may be written on device number %d POLLOUT\n", i); } if (fds[i].revents = !0) { /* A hangup has occurred on device number i. */ printf("A hangup has occurred on device number %d\n", i); } } } } return 0; }
Note: dev0 and dev1 are normal files. When I run the program, if no event occurred in dev0 and dev1, the message is displayed. But I was expecting when some write into the file happens, only then should it display the message. Am I wrong?
原文:https://stackoverflow.com/questions/12444679
更新时间:2023-03-17 17:03
最满意答案
像这样的东西可能会有所帮助
select * into [newtable2] from ( SELECT XL0.* FROM [Excel 12.0;HDR=Yes; Database=C:\TESTING.xlsx].[Sheet1$a1:e1] AS XL0 UNION ALL SELECT XL1.* FROM [Excel 12.0;HDR=No; Database=C:\TESTING.xlsx].[Sheet1$a3:e10] AS XL1 )
Something like this may help
select * into [newtable2] from ( SELECT XL0.* FROM [Excel 12.0;HDR=Yes; Database=C:\TESTING.xlsx].[Sheet1$a1:e1] AS XL0 UNION ALL SELECT XL1.* FROM [Excel 12.0;HDR=No; Database=C:\TESTING.xlsx].[Sheet1$a3:e10] AS XL1 )
相关问答
更多-
使用NSFetchedResultsController创建表格部分(Creating table sections with NSFetchedResultsController)[2022-06-14]
这很简单! 只需在其初始化程序中为hasDog提供一个sectionNameKeyPath (在本例中为hasDog )。 但有一点需要注意的是,分区名称分别为0和1 ,但它很容易治愈。 It's simple! Just provide the NSFetchedResultsController with a sectionNameKeyPath (which in this case would be hasDog) in its initializer. The one caveat to this ... -
导入表格的各个部分(Import sections of table)[2023-12-31]
像这样的东西可能会有所帮助 select * into [newtable2] from ( SELECT XL0.* FROM [Excel 12.0;HDR=Yes; Database=C:\TESTING.xlsx].[Sheet1$a1:e1] AS XL0 UNION ALL SELECT XL1.* FROM [Excel 12.0;HDR=No; Database=C:\TESTING.xlsx].[Sheet1$a3:e10] AS XL1 ) Something like this ... -
我没有设法找到任何一个带有2个部分的表格视图和2个部分中不同设计的单元格的示例。 可能吗? 对的,这是可能的 :) 这是您从UITableViewDataSource协议使用方法tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell地方。 你检查你要返回UITableViewCell的子类,创建一个实例,然后填充它然后你返回它。 所以,为了这个工作,你需要。 使用NI ...
-
以编程方式将表格和单元格添加到Table View Swift中(Programatically adding sections and cells to Table View Swift)[2022-07-12]
看看这个代码: import UIKit class TableViewController: UITableViewController { var names = ["Vegetables": ["Tomato", "Potato", "Lettuce"], "Fruits": ["Apple", "Banana"]] struct Objects { var sectionName : String! var sectionObjects : [ ... -
这是一种方式。 基本上你只需要清理浮子。 这里有一些关于CSS Floats的阅读: 所有关于浮动 CSS Floats 101 浮动财产的奥秘 * { box-sizing: border-box; } .jumbotron img { border: solid 1px black; margin-right: 14px; } #MiddleSection { clear: left; margin: 0px auto; } .MyArtic ...
-
sectionIndexTitlesForTableView与部分正确对齐(sectionIndexTitlesForTableView line up correctly with sections)[2023-06-27]
如果你只有A,C,F,S,T和部分索引标题,我不会看到@ Rudiger的方法是如何工作的。 使用MPMediaQuery时可能会出现这种情况。 为了解决这个问题,我已经实现了这个方法,tableview将滚动到正确的部分或下一个,如果你正在寻找的不存在。 - (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index { NS ... -
两个想法给你。 首先,如果它是一个小文件并且您知道所有节标题名称,则可以执行以下操作: data example; input id $ var1 - var5; datalines; NameA . . . . . A1 11 11 21 24 14 A2 9 8 1 2 3 A3 4 4 3 4 3 A4 2 9 1 2 4 Total 26 32 26 32 24 "" . . . . . ...
-
对于此示例,解决方案非常简单 - 在NSSortDescriptor排序描述符数组NSSortDescriptor一个NSSortDescriptor添加到现有的NSSortDescriptor 。 所以现在,获取的数据首先按部分排序,然后按字母顺序排序。 For this example solution was pretty straight - adding one NSSortDescriptor to existing one in NSFetchedResultsController sort ...
-
实际上在tableView:numberOfRowsInSection:您将返回整个exercises数组的计数。 因此,对于您的示例数据,每个部分将有两行。 尝试为每个部分制作一系列练习,然后编写如下代码: - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. if (sec ...
-
尝试这个 - struct Section { var name: String! var items: [String]! init(name: String, items: [String]) { self.name = name self.items = items } } import UIKit class Beta: UIViewController, UITableViewDataSource, UITableViewDelegate { @IBOutlet w ...