Package jnr.ffi.byref

Examples of jnr.ffi.byref.IntByReference


            String[] envp = getEnv(Daemon.class.getName() + "=daemon");
            List<String> argv = buildARGV(posix);

            jnr.ffi.Runtime runtime = jnr.ffi.Runtime.getSystemRuntime();
            Pointer NULL = Pointer.wrap(runtime, 0L);
            IntByReference child_pid = new IntByReference();

            int rs = posix.posix_spawnp(child_pid, argv.get(0), NULL, NULL,
                                        argv.toArray(new String[argv.size()]), envp);
            if (rs != 0) {
                throw new RuntimeException(posix.strerror(rs));
            }
            return Status.parent(child_pid.getValue());
        }
    }
View Full Code Here


        jnr.ffi.Runtime runtime = Runtime.getSystemRuntime();
        Pointer NULL = Pointer.wrap(runtime, 0L);

        SmallC sc = Library.loadLibrary("c", SmallC.class);

        final IntByReference oldlenp = new IntByReference(4);
        rs = sc.sysctl(new int[]{CTL_KERN, KERN_PROCARGS2, sc.getpid()}, 3,
                       NULL, oldlenp,
                       NULL, 0);
        if (rs != 0) {
            throw new IllegalStateException(sc.strerror(rs));
        }

        final Pointer oldp = Memory.allocateDirect(runtime, oldlenp.getValue());
        rs = sc.sysctl(new int[]{CTL_KERN, KERN_PROCARGS2, sc.getpid()}, 3,
                       oldp, oldlenp,
                       NULL, 0);
        if (rs != 0) {
            throw new IllegalStateException(sc.strerror(rs));
        }

        class ProcessStuffReader
        {
            private int offset = 0;

            private final int          argc;
            private final int          size;
            private final List<String> argv;

            ProcessStuffReader()
            {
                this.size = oldlenp.getValue();
                argc = readInt();
                readString(); // exec path?
                skipNulls();
                List<String> argv = new ArrayList<String>(argc);
                for (int i = 0; i < argc; i++) {
View Full Code Here

TOP

Related Classes of jnr.ffi.byref.IntByReference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.