switch to room list switch to menu My folders
Go to page: First ... 97 98 99 100 [101] 102 103 104 105 ... Last
[#] Fri Jul 18 2014 08:29:28 EDT from fleeb @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

After the first fork, I setsid for a new process group. After the second fork, I open to /dev/null, dup2( fd, STD*_FILENO), then close(fd). I then do the umask(027), set up my signals, create a pid file, etc.

Should I do that earler?

I'm seriously thinking about modifying this code to make it so it starts according to command line parameters... no parameters, no forks, --fork makes it fork once, --daemon makes it fork twice, and --emitstop makes it signal SIGSTOP when it's properly running (after two forks). But something in me finds it irritating to think I might have a need to alter the code in such a way, when you'd think just daemonizing it like any other daemonizing service should do the trick.

I've also considered another way that involves using the pre-start command to actually start the executable, pre-stop to actually stop it, and create a script that monitors that the pid file I create actually refers to a running process to ensure that it's running, since apparently upstart is too broken in this distribution to handle a daemon (unless my daemon is fubared, but the code looks like any other daemonization code I've seen elsewhere, so.. I dunno).

[#] Fri Jul 18 2014 09:34:23 EDT from fleeb @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]


I wrote a dirt-simple daemon.c that just does the minimum amount of work to daemonize (eventually going to while(1){sleep(1);}), and upstart has no problems with it.

So this means I need to figure out what's wrong with my own attempt to daemonize... something isn't quite working correctly.

strace is still borked with even the simple daemon.c, though, so, plegh.

[#] Fri Jul 18 2014 10:50:55 EDT from fleeb @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Aaand, now I've figured it all out.

Firstly, I made some incredibly stupid coding errors. I thought I was daemonizing correctly (and at one time I was), but I failed to consider some changes I had made... or more to the point, I forgot to test that I was actually daemonizing after making those changes.

The 'dup2' thing that I learned somewhere else was utter crap... one of the problems of reading a lot of different bits of code from different places is that not everyone who seems like they know what they're doing actually know what they're doing. I read up on the command, thought carefully about what it was actually doing, then threw it away and did something simpler and smarter (a straightforward 'close(STD*_FILENO)').

I'm gratified to know that 'sudo stop [service]' in upstart executes a kill -TERM instead of just a wanton killing of the process, so I have the opportunity to clean up properly.

Heh... so, there you have it. A Windows developer's stumbling, bumbling learning how to upstart.

Hrm... now, if I could figure out a way to get it to start *when* it should start (instead of crashing and being restarted by upstart), I'd have something that provides less impact to the initialization of the machine.

[#] Fri Jul 18 2014 12:20:45 EDT from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

are you running with ulimit -c unlimited?

[#] Fri Jul 18 2014 12:28:17 EDT from fleeb @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

ulimit -c returns '0'.

I found the answer to my question.

start on (local-filesystems and net-device-up IFACE!=lo)

That line within the .conf file you put in /etc/init (not /etc/init.d) fixes the issue. Now, it starts when the interface I need is running.

I could maybe get away without the local-filesystems, but I realize that I need to look at configuration files, so it makes sense to keep that as a dependency as well. Not that a network tends to run before the filesystem, but I guess when you're massively parralleling the startup, it's always a possibility.

[#] Fri Jul 18 2014 16:15:23 EDT from IGnatius T Foobar @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Don't bother optimizing for upstart; it's going away in favor of systemd, even in Ubuntu.

systemd can be told to run stuff in the foreground, as if it were called directly from /etc/inittab under old init. I don't know how kosher that is (probably not very) but it does work.

[#] Fri Jul 18 2014 17:44:28 EDT from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

called directly from /etc/inittab under old init. I don't know how
kosher that is (probably not very) but it does work.

Not very kosher under old init, because you had to change runlevels just to enable/disable a specific service.

Might not be considered such a bad thing under a fancier init.

[#] Fri Jul 18 2014 22:20:13 EDT from fleeb @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

I'm intending to write configurations for the three styles of startup.

I have a couple of sysv scripts made, and (now) the upstart. Next, I'll want to create one for systemd.

At the very least, supporting these more recent inits allow me to take advantage of parrallelization, which strikes me as a good thing.

[#] Sat Jul 19 2014 12:53:58 EDT from IGnatius T Foobar @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Hmm, I just thought of something:

Some programs use -d (debug) to force them to stay in the foreground (and spew debug info)

Some programs use -d (daemon) to force them to go into the background

This is an atrocity. I blame the previous owner of my old house, whose last name begins with the letter D, for this atrocity.

[#] Sat Jul 19 2014 14:34:00 EDT from zooer @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Stupid standards.

[#] Sat Jul 19 2014 14:34:08 EDT from zooer @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

I would call Linus.

[#] Sat Jul 19 2014 14:54:14 EDT from fleeb @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

I am not sure, but -v seems to be more popular for debugging info (e.g. 'verbose').
But, again, I kinda feel like I'm dipping my toe into all of this.

[#] Sat Jul 19 2014 15:47:25 EDT from zooer @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Free network equipment shape gallery designed to allow #LibreOffice and #OpenOffice users to create network

[#] Tue Jul 22 2014 08:48:54 EDT from zooer @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Learn VIm while playing a game.

Seems to me you have to know Vim to play the game, I really didn't get too far before becoming frustrated. You
are the black cursor not the guy in the center of the screen.

[#] Tue Jul 22 2014 09:29:20 EDT from fleeb @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

that's rather neat, actually.

I'd love to play that sometime when I'm not at work.

[#] Tue Jul 22 2014 10:05:00 EDT from fleeb @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Playing with Fedora today.

Maybe I don't quite understand the issue that lead someone to say something like this, but supposedly we can't build binary RPMs because we haven't paid for a Red Hat Developer's license or somesuch.

That doesn't strike me as true, though, so I'm looking into things myself.
Hence, installing Fedora. Well, that, and I wanted to look at systemd and see how well I can set up our services to auto-start in that environment's configuration scheme.

Lots of toe-dipping this year.

[#] Tue Jul 22 2014 10:06:50 EDT from fleeb @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

I'll say this for Fedora, though... it looks pretty out of the box.

But I'm not sure I like the whole 'grab the screen and pull up' screen-locking mechanism they use. I'm sure I can configure something else, but... this isn't a touch-screen.

[#] Tue Jul 22 2014 14:18:23 EDT from dothebart @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

fleeb, you should use centos to compile.

these are guaranteed to produce library dependencies with RHEL.

with fedora you've got bleeding edge, and may not find your libs over there.

[#] Tue Jul 22 2014 15:10:27 EDT from fleeb @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Oh, nice to know!

I've at least managed to learn how to work with systemd with Fedora. But it's a little weird that one form of logging to syslog works, while the other one I use doesn't (yeah, this is difficult to explain well).

[#] Wed Jul 23 2014 00:45:35 EDT from ax25 @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]


Mon Jul 07 2014 07:51:09 AM EDT from dothebart @ Uncensored

Maddog is digitizing his ye olde VHS-Tapes:

Linus talk at dec.

Nice!  Thanks for that.

Go to page: First ... 97 98 99 100 [101] 102 103 104 105 ... Last