[Home]

Summary:ASTERISK-09007: safe asterisk script crashes with bad file descriptor, asterisk doesnt start at boot
Reporter:username (username)Labels:
Date Opened:2007-03-14 09:50:37Date Closed:2007-06-26 13:52:01
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Core/Configuration
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:The function run_asterisk inside /usr/sbin/safe_asterisk crashes on the line nice -n ( just near the top, inside the first if branch ). There must be some problem with the redirection of the std input/output in that line, as in /var/log/boot the error appears as: "Syntax error: bad fd number".
When I comment out all the redirection I get no error.

As a temporary fix I set the TTY variable to "" and asterisk seems to load correctly at startup.

Im not much of a linux user, so I don't know if there is a way to query whether redirection to/from a /dev/tty* device would crash the script before attempting it.

Im running ubuntu server edition inside a virtual machine.

Thanks.
Comments:By: Clod Patry (junky) 2007-03-15 22:32:07

which specific Ubuntu version? 6.10?
Which Virtual machine?

By: username (username) 2007-03-16 04:09:06

Yes, 6.10.

More specifically, 6.10.17-10-server is what uname -r says.

Its VMware server 1.0.2, running on windows.

Thanks.

By: username (username) 2007-03-21 06:50:56

Is there any more I can do?

By: Clod Patry (junky) 2007-03-22 22:12:10

In some system, which doesnt have TTY, that's the correct fix.
Without ur VM, everything goes well too?

By: username (username) 2007-03-23 04:54:28

I found the cause of the problem. Apparently the newer Ubuntu uses "dash" as /bin/sh, and not bash. dash is more restrictive than bash in terms of syntax. In particular it requires a file descriptor number for >& redirection, not a named file.

If I change the error line from:
nice -n ${PRIORITY} ${ASTBINDIR}/asterisk ${CLIARGS} ${ASTARGS} >& /dev/${TTY} < /dev/${TTY}

to:
nice -n ${PRIORITY} ${ASTBINDIR}/asterisk ${CLIARGS} ${ASTARGS} > /dev/${TTY} 2>1& < /dev/${TTY}

Then Asterisk starts and correctly redirects stdin/out. This also seems to work in bash.

Should this be changed?

By: username (username) 2007-03-29 03:43:16

Just to bump this and ask what should I do now?

By: Sean Coates (scoates) 2007-04-02 12:10:25

I fixed this by changing the shebang line (line 1) from:
#!/bin/sh
to:
#!/bin/bash

FWIW, this has nothing to do with vmware, and is a bash/dash/sh problem, as "username - reporter" indicated.

S

By: Clod Patry (junky) 2007-04-02 12:12:55

i dont know if we should change that.

By: username (username) 2007-04-03 03:17:15

Just curious as to why you'd rather not change it.

After all, if it doesn't break anything, why not? If it does break something then maybe leave it the way it is. It is just a matter of either choosing to explicitly use bash (if you want to support bashes more free syntax), or using stricter POSIX /bin/sh scripting syntax to support a wider variety of shells.

Thanks.

By: username (username) 2007-04-16 03:53:41

One last bump if I may.

By: Jon Creasy (johann8384) 2007-06-26 12:13:48

I'm experiencing this issue as well as the Asterisk process randomly ending with no log output or a dump. I'm also on the same Ubuntu version.

I'm working on getting some more details which I will pass along when I can.

I began using bash explicitly but I am still having a problem that the asterisk process dies without any output. It may or may not be related.



By: Tilghman Lesher (tilghman) 2007-06-26 13:51:13

We've asked Ubuntu repeatedly that they change their startup scripts to use #!/bin/dash instead of changing their symlink, and they've refused, so there's little that we can do to fix this problem.  There's unfortunately an incompatibility between dash and bash, and we need to ensure our startup scripts run on other platforms, such as FreeBSD and Solaris, which they do just fine.

This is an Ubuntu problem, and it's squarely within their power to fix it.