getsid - Get Session ID Utility

This topic was published by and viewed 1933 times since "". The last page revision was "".

Viewing 1 post (of 1 total)
  • Author

  • DevynCJohnson
    • Topics - 437
    • @devyncjohnson

    "getsid" is an open-source Linux command-line utility for obtaining the Session ID (SID) of a given Process ID (PID). This software is licensed under the GNU Lesser General Public License (LGPLv3 - and is made by Devyn Collier Johnson <[email protected]>.

    To compile getsid, open a terminal in the same directory as the source code. Then, execute gcc -O3 -pedantic -Wall -std=gnu11 ./getsid.c -o ./getsid or gcc ./getsid.c -o ./getsid.

    To install getsid, move the compiled binary to /usr/bin/ and then make it executable (using Root privileges) - cp ./getsid /usr/bin/getsid && chown root:root /usr/bin/getsid && chmod 755 /usr/bin/getsid.

    To use getsid, type the command and then specify a PID. The command will return the Session ID of the specified PID. If no PID is specified, then a PID of "0" is assumed.

    getsid Usage
    getsid Usage

    Download src and 64-bit binary

    Created by Devyn Collier Johnson
    <[email protected]>
    GNU Lesser General Public License v3
    Copyright (c) Devyn Collier Johnson, All rights reserved.
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 3.0 of the License, or (at your option) any later version.
    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    Lesser General Public License for more details.
    You should have received a copy of the GNU Lesser General Public
    License along with this library.
    #define _GNU_SOURCE
    #include <stdio.h>
    #include <stdlib.h>
    #include <unistd.h>
    #include <sys/syscall.h>
    #include <sys/types.h>
    //getsid() - returns the Session ID
    int main(int argc, char *argv[]) {
    	int pid, sid;
    	if (argc > 2) {
    		printf("Expected one or no parameters, but was given %d\n", argc - 1);
    		return 1;
    	} else if (argc == 1) {
    		pid = 0;
    	} else {
    		pid = atoi(argv[1]);
    	pid_t getsid(pid_t pid);
    	sid = getsid(pid);
    	printf("%d\n", sid);
    	return 0;
    You must be logged in to view attached files.
Viewing 1 post (of 1 total)