From 48613008a5c383742d61221da84c2f7ae063a9c0 Mon Sep 17 00:00:00 2001 From: "Manuel Amador (Rudd-O)" Date: Thu, 18 Aug 2022 12:17:23 +0000 Subject: [PATCH] Mlock. --- bin/qvm-pass | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/bin/qvm-pass b/bin/qvm-pass index 061ce82..4fa10b9 100755 --- a/bin/qvm-pass +++ b/bin/qvm-pass @@ -1,5 +1,6 @@ #!/usr/bin/python3 -u +import ctypes import argparse import base64 import getpass @@ -368,9 +369,20 @@ def pass_manage(*args, **kwargs): return send_args(PASS_MANAGE, *args, **kwargs) +def mlockall(): + MCL_CURRENT = 1 + MCL_FUTURE = 2 + libc = ctypes.CDLL("libc.so.6", use_errno=True) + result = libc.mlockall(MCL_CURRENT | MCL_FUTURE) + if result != 0: + raise Exception("cannot lock memmory, errno=%s" % ctypes.get_errno()) + + # -------------------- Begin ---------------------- +mlockall() + arguments = sys.argv[1:] if "--help" in arguments or "-h" in arguments or "-?" in arguments: parser_for_subcommands.parse_known_args(arguments)