Newbie question: Daemon mode in Linux

Started by jopython, September 14, 2010, 08:15:24 AM

Previous topic - Next topic

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
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

#1
Not familiar with setsid, but tried this on Mac OS X:
> (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:
(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

#2
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

#3
I think spawn keeps running as well?

Lutz

#4
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:
$ 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

#5
newlisp qa-specific-tests/qa-bench

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

#6
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

#7
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

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

Yep we have a hundred of them.