Giter Club home page Giter Club logo

Comments (7)

rofl0r avatar rofl0r commented on July 22, 2024 1

there's plenty of ways to background a task:

  • nohup
  • screen
  • tmux
  • inetd
  • write your own simple systemd service script
[Unit]
Description=My Service NAME
After=network.target

[Service]
Type=simple
User=YOUR_USERNAME
WorkingDirectory=/home/YOUR_USERNAME/
ExecStart=/path/to/binary
Restart=always #on-failure # or always, on-abort, etc

[Install]
WantedBy=multi-user.target

save as /etc/systemd/system/SERVICENAME.service

from microsocks.

rofl0r avatar rofl0r commented on July 22, 2024 1
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>

void daemonize(void) {
        pid_t pid = fork();
        if (pid < 0) {
                exit(1);
        }
        if (pid > 0) exit(0);
        setsid(); /* obtain a new process group */
        int fd;
        for (fd = getdtablesize(); fd >= 0; --fd) close(fd); /* close all descriptors */
        fd = open("/dev/null", O_RDWR); dup(fd); dup(fd); /* handle standart I/O */
}

here's the code to deamonize (from libulz), you can add it to the file and call it from main() but i think your issue is PEBKAC so i'm not gonna put this into the official version...

from microsocks.

mckaygerhard avatar mckaygerhard commented on July 22, 2024

of course can solved rudimentary with "--make-pidfile" and "--background" but there's some plans to make the program background? (i already know its light and simple but well..)

from microsocks.

mckaygerhard avatar mckaygerhard commented on July 22, 2024

thanks @rofl0r but as i said, i created but the binary does not acept the parameters (custon port sources from a file)

the service name and the init daemon works as i posted in second comment, but due the nature of the executable, does not permit control, reload or parse custom parameters..

from microsocks.

rofl0r avatar rofl0r commented on July 22, 2024

the key point of my answer (but maybe it was not clear since i didn't state it explicitly) is that there are so many ways you can background a task via standard tools that i don't see the need to add the functionality to microsocks itself.
if you want to background it for the duration of your computer's uptime, i'd recommend you just start screen, and then launch microsocks from within that screen session, then close the terminal. if you want to have it booted automatically on startup, use a systemd service.

from microsocks.

mckaygerhard avatar mckaygerhard commented on July 22, 2024

yeah, it works with noup, also with screen, but only if i do manually.. i mean if i put in other script and try to automatically pass arguments, seems do not work.. dont worry, too busy for simple task.. thanks in any case.

from microsocks.

mckaygerhard avatar mckaygerhard commented on July 22, 2024

hey solved! was a stupid misctake, the parse variable for the arguments was different, i could not see due i use a remote screen so image are blurry and well..

i made a debian package if interesting.. for Debian 7, 8, and 9, for debian 6, 5, and 4 too bit at venenux mail list.. here-s the procedure to install:

https://software.opensuse.org//download.html?project=home%3Avegnuli%3Ainternet&package=microsocks

echo 'deb http://download.opensuse.org/repositories/home:/vegnuli:/internet/Debian_$(lsb_release -s -r | cut -d . -f 1).0/ /' > /etc/apt/sources.list.d/home:vegnuli:internet.list
apt-get update
apt-get install microsocks

from microsocks.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.