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
>>>
編集:
Nemosのリマインダー経由get_errno
で、22 (無効な引数) を返すことができます。驚きではありません。どのように電話すればよいreboot()
ですか? 関数が期待する引数を渡していないことは明らかです。=)