Newbie question: Daemon mode in Linux

Machine-specific discussion
Unix, Linux, OS X, OS/2, Windows, ..?
Locked
jopython
Posts: 123
Joined: Tue Sep 14, 2010 3:08 pm

Newbie question: Daemon mode in Linux

Post by jopython »

I want newlisp to run in the background while I am away from the shell.
In a 'traditional' UNIX scripting language like Perl, Python the setsid function will have to be called from the inside.
In the Bash/Korn shell we have to invoke

Code: Select all

 nohup script_name &
Is there a way to avoid the nohup command for the newlisp script?
The documentation from what I understood provides TCP/IP server mode via sockets and that is not what I am looking for.
Thanks everyone.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: Newbie question: Daemon mode in Linux

Post by Lutz »

Not familiar with setsid, but tried this on Mac OS X:

Code: Select all

> (import "libc.dylib" "setsid")
setsid<9487FD98>
> (setsid)
-1
> (sys-error)
(1 "Operation not permitted")
> 
But using 'fork' works on MAC OS X and UBUNTU Linux:

Code: Select all

(fork (while true (append-file "log.txt" (string (date) "\n")) (sleep 1000)))
(exit)
The forked process keeps on running even after exiting and closing the terminal window. It also kept on running on a remote OSX machine on my home network even after closing the SSH session, probably because the desktop on that machine is still running under my user id.

jopython
Posts: 123
Joined: Tue Sep 14, 2010 3:08 pm

Re: Newbie question: Daemon mode in Linux

Post by jopython »

Thanks for the quick response which works.
FYI, I compiled newlisp on zLinux (for the IBM mainframe) with the config_alt option.
Works fine for me so far.

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Re: Newbie question: Daemon mode in Linux

Post by cormullion »

I think spawn keeps running as well?

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: Newbie question: Daemon mode in Linux

Post by Lutz »

Yes, 'spawn' should work as well. I used 'fork' as the more elementary operation, and we are not interested in return values or messaging, as the parent exits anyway.

I would love to find out how fast this goes on an IBM mainframe:

Code: Select all

$ newlisp qa-specific-tests/qa-bench 

Benchmarking all non I/O primitives
    2418.0 ms
>>>>> Performance ratio: 1.00 (1.0 on Mac OS X, 1.83 GHz Intel Core 2 Duo)

jopython
Posts: 123
Joined: Tue Sep 14, 2010 3:08 pm

Re: Newbie question: Daemon mode in Linux

Post by jopython »

newlisp qa-specific-tests/qa-bench

Code: Select all

Benchmarking all non I/O primitives
    2134.6 ms
>>>>> Performance ratio: 0.89 (1.0 on Mac OS X, 1.83 GHz Intel Core 2 Duo)

jopython
Posts: 123
Joined: Tue Sep 14, 2010 3:08 pm

Re: Newbie question: Daemon mode in Linux

Post by jopython »

For SUN SPARC running a 1350MHZ processor it is:

newlisp qa-specific-tests/qa-bench

Benchmarking all non I/O primitives
5579.9 ms
>>>>> Performance ratio: 2.24 (1.0 on Mac OS X, 1.83 GHz Intel Core 2 Duo)

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: Newbie question: Daemon mode in Linux

Post by Lutz »

The fastest I had so far, was this:

Benchmarking all non I/O primitives
1504.9 ms
>>>>> Performance ratio: 0.63 (1.0 on Mac OS X, 1.83 GHz Intel Core 2 Duo)

on my ISP's machine at nearlyfreespeech.net, no clue what kind of machine that is, propbably some 2.8 GHZ CPU

on an older Sparc SUNW,Ultra-2:

Benchmarking all non I/O primitives
24150.2 ms
>>>>> Performance ratio: 9.52 (1.0 on Mac OS X, 1.83 GHz Intel Core 2 Duo)

when I heard "IBM mainframe", I thought, I would see this :-)

Benchmarking all non I/O primitives
24.1 ms
>>>>> Performance ratio: 0.01 (1.0 on Mac OS X, 1.83 GHz Intel Core 2 Duo)

but I guess many zLinux images run on that mainframe CPU sharing the power.

jopython
Posts: 123
Joined: Tue Sep 14, 2010 3:08 pm

Re: Newbie question: Daemon mode in Linux

Post by jopython »

but I guess many zLinux images run on that mainframe CPU sharing the power.
Yep we have a hundred of them.

Locked