Description:fix ioctl console failed

Feature or Bugfix:Bugfix
Binary Source: No

Signed-off-by: cat <chenjinxiang3@huawei.com>
This commit is contained in:
cat 2024-04-13 06:36:11 +00:00
parent 60c84f94f1
commit 274a87195b

View File

@ -595,13 +595,13 @@ static void RedirectStdio(int fd)
#endif
#ifndef __LITEOS_M__
static int OpenStdioDevice(const char *dev)
static int OpenStdioDevice(const char *dev, int flag)
{
setsid();
WaitForFile(dev, WAIT_MAX_SECOND);
int fd = open(dev, O_RDWR);
if (fd >= 0) {
ioctl(fd, TIOCSCTTY, 0);
ioctl(fd, TIOCSCTTY, flag);
RedirectStdio(fd);
if (fd > 2) {
close(fd);
@ -616,14 +616,14 @@ static int OpenStdioDevice(const char *dev)
int OpenConsole(void)
{
#ifndef __LITEOS_M__
return OpenStdioDevice("/dev/console");
return OpenStdioDevice("/dev/console", 1);
#endif
}
int OpenKmsg(void)
{
#ifndef __LITEOS_M__
return OpenStdioDevice("/dev/kmsg");
return OpenStdioDevice("/dev/kmsg", 0);
#endif
}