我已经在我的 Linux 内核中定义了一个“helloworld”系统调用并重新编译了它。系统调用的代码是:
#include<linux/kernel.h>
#include<linux/init.h>
#include<linux/sched.h>
#include<linux/syscalls.h>
#include "processInfo.h"
asmlinkage long sys_listProcessInfo(void)
{
printk("Hello World. My new syscall..FOSS Lab!\n");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
但是,当我从具有另一个内核版本(不包括此系统调用)的同一操作系统调用此系统调用时,请使用以下代码:
#include<stdio.h>
#include<linux/kernel.h>
#include<sys/syscall.h>
#include<unistd.h>
int main()
{
long int var = syscall(326);
printf("Returning: %ld\n",var);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
该变量var的值为 -1。我想知道如何var获取 -1 而不是显示错误。
我想在主窗口关闭时关闭主窗口打开的所有其他窗口。
请在下面找到最小值。我正在测试的代码:
from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton, QLabel, QVBoxLayout, QWidget
import sys
class AnotherWindow(QWidget):
"""
This "window" is a QWidget. If it has no parent, it
will appear as a free-floating window as we want.
"""
def __init__(self):
super().__init__()
layout = QVBoxLayout()
self.label = QLabel("Another Window")
layout.addWidget(self.label)
self.setLayout(layout)
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.button = QPushButton("Push for Window")
self.button.clicked.connect(self.show_new_window)
self.setCentralWidget(self.button)
def show_new_window(self, checked):
self.w = AnotherWindow()
self.w.show()
def close_another_window(self):
if self.w:
self.w.close()
app = QApplication(sys.argv)
w = MainWindow()
app.aboutToQuit.connect(w.close_another_window) …Run Code Online (Sandbox Code Playgroud)