我试图reboot通过Python中的libc 调用函数ctypes,我只是无法让它工作.我一直在引用该man 2 reboot页面(http://linux.die.net/man/2/reboot).我的内核版本是2.6.35.
下面是来自交互式Python提示的控制台日志,我试图让我的机器重新启动 - 我做错了什么?
为什么不ctypes.get_errno()工作?
>>> from ctypes import CDLL, get_errno
>>> libc = CDLL('libc.so.6')
>>> libc.reboot(0xfee1dead, 537993216, 0x1234567, 0)
-1
>>> get_errno()
0
>>> libc.reboot(0xfee1dead, 537993216, 0x1234567)
-1
>>> get_errno()
0
>>> from ctypes import c_uint32
>>> libc.reboot(c_uint32(0xfee1dead), c_uint32(672274793), c_uint32(0x1234567), c_uint32(0))
-1
>>> get_errno()
0
>>> libc.reboot(c_uint32(0xfee1dead), c_uint32(672274793), c_uint32(0x1234567))
-1
>>> get_errno()
0
>>>
Run Code Online (Sandbox Code Playgroud)
编辑:
通过Nemos提醒 - 我可以get_errno返回22(无效参数).不足为奇.我该怎么打电话reboot()?我显然没有传递函数期望的参数.=)