[SERVER-2312] Mongo keeps standard output open when --fork used Created: 30/Dec/10  Updated: 12/Jul/16  Resolved: 30/Dec/10

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Roger Bodamer (Inactive) Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Solaris


Operating System: ALL
Participants:

 Description   

[from jfeibusc@ebay.com; john feibusch]

When you start Mongo with the --fork option, it keeps a connection to the terminal. That means that if you have started Mongo from an ssh session, then ssh will not close normally.

It would be nice if you could make it so that ssh will close normally after starting Mongo in the background.

On Solaris, I had to do a double-fork to accomplish this - fork, close standard input,output, and error, then fork again. The middle process would then exit. I'm not sure if this is necessary on Linux.

Here's a session log:

[root@qa-nosql01 ~]# /opt/mongodb/bin/mongod --version
db version v1.6.2, pdfile version 4.5
Thu Dec 30 15:53:04 git version: aef371ecf5d2a824f16ccdc3b745f3702165602f

[root@qa-nosql07 ~]# /opt/mongodb/bin/mongod --dbpath /data/db/config --replSet johnf --fork --logpath /data/db/log/mongo.log
all output going to: /data/db/log/mongo.log
forked process: 27523

[root@qa-nosql07 ~]# ls -l /proc/27523/fd
total 0
l-wx------ 1 root root 64 Dec 30 15:30 0 -> /dev/null
lrwx------ 1 root root 64 Dec 30 15:30 1 -> /dev/pts/0
lrwx------ 1 root root 64 Dec 30 15:30 10 -> /data/db/config/local.3
lr-x------ 1 root root 64 Dec 30 15:30 2 -> /dev/null
lr-x------ 1 root root 64 Dec 30 15:30 3 -> /dev/urandom
l-wx------ 1 root root 64 Dec 30 15:30 4 -> /data/db/log/mongo.log
lrwx------ 1 root root 64 Dec 30 15:30 5 -> /data/db/config/mongod.lock
lrwx------ 1 root root 64 Dec 30 15:30 6 -> /data/db/config/local.ns
lrwx------ 1 root root 64 Dec 30 15:30 7 -> /data/db/config/local.0
lrwx------ 1 root root 64 Dec 30 15:30 8 -> /data/db/config/local.1
lrwx------ 1 root root 64 Dec 30 15:30 9 -> /data/db/config/local.2

[root@qa-nosql07 ~]# tty
/dev/pts/0



 Comments   
Comment by Roger Bodamer (Inactive) [ 30/Dec/10 ]

awesome.. will pass that along

Comment by Eliot Horowitz (Inactive) [ 30/Dec/10 ]

This was fixed somewhere in 1.6
Try 1.6.5

Generated at Thu Feb 08 02:59:35 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.