小编Ton*_*osi的帖子

未定义的系统调用如何返回 -1?

我已经在我的 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 而不是显示错误。

c linux linux-kernel

5
推荐指数
1
解决办法
432
查看次数

pyqt5中主窗口关闭时如何关闭其他窗口

我想在主窗口关闭时关闭主窗口打开的所有其他窗口。

请在下面找到最小值。我正在测试的代码:

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)

python pyqt5

5
推荐指数
1
解决办法
8630
查看次数

kill和kill -9有什么区别?

谁能解释一下kill和kill -9之间的区别。提前致谢。

linux shell kill process

-3
推荐指数
1
解决办法
1307
查看次数

标签 统计

linux ×2

c ×1

kill ×1

linux-kernel ×1

process ×1

pyqt5 ×1

python ×1

shell ×1