我用C++写了一个Linux守护进程。代码如下所示:
int main(int argc, char** argv)
{
daemon(1, 0); // Daemonize itself, retaining the current working directory and redirecting stdin, stdout and stderr to /dev/null.
// My program logic goes here
}
问题是,我的程序逻辑偶尔会抛出异常。如何捕获异常,以便知道哪里出了问题?
我知道对于普通的控制台应用程序,未捕获的异常将被转储到控制台。在
这段代码在Windows中工作正常,但在Linux中抛出一个java.text.ParseException:
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", new Locale("es", "ES"));
df.setLenient(false);
Date date = df.parse("1901-01-01 00:00:00");
System.out.println(date);
Windows输出:
Tue Jan 01 00:00:00 CET
我需要可以在Visual和Mono下编译并在Linux或Windows上运行的代码。
我需要返回可用的可用空间,只需要返回到目录的路径。
在窗户上我会做一些类似于-
var file = new FileInfo(path);
var drive = new DriveInfo(file.Directory.Root.FullName);
return drive.AvailableFreeSpace;
然而,在Linux上,这似乎会引发一个参数异常。file.Directory.Root.FullName返回'/‘。DriveInfo抛出“驱动器名不存在”的参数异常
有什么想法吗?
我在三星SoC s3c6410 (ARM11)上有linux板。我使用buildroot构建rootfs : Python 2.7.1,uClibc-0.9.31。Linux内核: Linux buildroot 2.6.28.6 #177 Mon Oct 3 12:50:57 EEST 2011 armv6l GNU/Linux
我的应用程序是用python编写的,在一些神秘的情况下会引发以下异常:
1)异常:
File "./dfbUtils.py", line 3209, in setItemData
ValueError: (4, 'Interrupted s
在python代码片段中,我使用了os.mkdir(linux_path),出于测试目的,我在Windows中运行python代码。
然而,即使当windows中的linux路径不可用时,代码仍在运行,并且仍然没有创建路径(如预期的那样)。但是代码应该会抛出一些错误,因为代码试图在windows中创建一个linux路径,但是仍然没有错误。
if not os.path.exists(<Linux_path>):
os.makedirs(<Linux_path>)
谁能帮助一下如何处理这里的异常/错误情况。
提前谢谢。阿尔琼。
我尝试了以下代码:
String url = "smb://remotehost/SharedPath/Comp/NG/";
NtlmPasswordAuthentication auth2 = new
NtlmPasswordAuthentication(null,"user", "password");
SmbFile dir = new SmbFile(url, auth);
for (SmbFile f : dir.listFiles())
{
if(f.getName().contains("Test")) //s